view anagram/guisupport/errordc.cpp @ 15:f5acaf0c8a29

Don't cast through "volatile int". Causes a gcc warning nowadays. XXX: should put something else back here to frighten the optimizer
author David A. Holland
date Tue, 31 May 2022 01:00:55 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * errordc.cpp
 */

#include "brt.h"
#include "dc.h"
#include "error.h"
#include "errordc.h"
#include "stacks.h"
#include "wm1.h"

//#define INCLUDE_LOGGING
#include "log.h"


void error_display_dc::synchCursor(unsigned ln) const {
  set_text_line(errorList[ln].line, errorList[ln].column, 0);
}

//dc *error_display_cursor(dc *d, int k);

error_display_dc::error_display_dc(void)
  : dc("Warnings")
{
  LOGSECTION("error_display_dc::error_display_dc");
  LOGV((int) this);
  cint size;
  unsigned i, dw, n;
  //extern cint cursor_bar_size;
  int nerrors = errorList.size();
  LOGV(nerrors);

  for (i = dw = 0; i < nerrors; i++) {
    getLine(i);
    n = rcs();
    if (n > dw) {
      dw = n;
    }
  }
  size.x = dw;
  size.y = nerrors;
  des->d_size = size;
}

void error_display_dc::getLine(unsigned ln) const {
  LOGSECTION("error_display_dc::getLine");
  Error &e=errorList[ln];
  if (e.file.exists()) {
    ssprintf("%s: Line %d, Col %d: %s", e.file.pointer(), e.line, e.column,
	     e.message.pointer());
  }
  else {
    ssprintf("Line %d, Col %d: %s", e.line, e.column,  e.message.pointer());
  }
}

AgString error_display_dc::findHelpTopic() {
  dc_ref window;
  char *q;

  //update_screen(this);
  getLine(des->c_loc_doc.y);
  q = string_base;
  if (strncmp(q, "Line ", 5) == 0) {
    q = strchr(q, ':');
    if (q) {
      q += 2;
    }
  }
  AgString topic = q;
  rcs();
  return topic;
}