diff anagram/guisupport/errordc.cpp @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/anagram/guisupport/errordc.cpp	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,78 @@
+/*
+ * 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;
+}
+