summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar MichalMoskal <unknown>2011-01-26 02:42:20 +0000
committerGravatar MichalMoskal <unknown>2011-01-26 02:42:20 +0000
commit12c1192db3954460e79ff71cb3a42c61f9f26784 (patch)
treefe22d10c21353672bcf1848ef03fdb60e8b37f7b
parentd10092583e4f3ee31772300ca097a616ca2713a2 (diff)
Display line numbers (useful for finding what the error message refers to)
-rw-r--r--Source/ModelViewer/DataModel.cs21
-rw-r--r--Source/ModelViewer/Namer.cs34
-rw-r--r--Source/ModelViewer/SourceView.cs2
3 files changed, 33 insertions, 24 deletions
diff --git a/Source/ModelViewer/DataModel.cs b/Source/ModelViewer/DataModel.cs
index 807158e2..f8a9abf0 100644
--- a/Source/ModelViewer/DataModel.cs
+++ b/Source/ModelViewer/DataModel.cs
@@ -47,27 +47,6 @@ namespace Microsoft.Boogie.ModelViewer
public string Header;
public string RichTextContent;
public int Location;
-
- public static void RtfAppend(StringBuilder sb, char c, ref int pos)
- {
- pos++;
- switch (c) {
- case '\r': pos--; break;
- case '\\': sb.Append("\\\\"); break;
- case '\n': sb.Append("\\par\n"); break;
- case '{': sb.Append("\\{"); break;
- case '}': sb.Append("\\}"); break;
- default: sb.Append(c); break;
- }
- }
-
- public static void RtfAppendStateIdx(StringBuilder sb, string label, ref int pos)
- {
- label += ".";
- pos += label.Length;
- sb.Append(@"{\sub\cf5\highlight4 ").Append(label).Append("}");
- }
-
}
public interface IState
diff --git a/Source/ModelViewer/Namer.cs b/Source/ModelViewer/Namer.cs
index 9191055b..749eb274 100644
--- a/Source/ModelViewer/Namer.cs
+++ b/Source/ModelViewer/Namer.cs
@@ -275,6 +275,34 @@ namespace Microsoft.Boogie.ModelViewer
return true;
}
+
+ protected virtual void RtfAppend(StringBuilder sb, char c, ref int pos)
+ {
+ pos++;
+ switch (c) {
+ case '\r': pos--; break;
+ case '\\': sb.Append("\\\\"); break;
+ case '\n': sb.Append("\\par\n"); break;
+ case '{': sb.Append("\\{"); break;
+ case '}': sb.Append("\\}"); break;
+ default: sb.Append(c); break;
+ }
+ }
+
+ protected virtual void RtfAppendStateIdx(StringBuilder sb, string label, ref int pos)
+ {
+ label += ".";
+ pos += label.Length;
+ sb.Append(@"{\sub\cf5\highlight4 ").Append(label).Append("}");
+ }
+
+ protected virtual void RtfAppendLineNo(StringBuilder sb, int num, ref int pos)
+ {
+ string n = string.Format("{0:0000}: ", num);
+ pos += n.Length;
+ sb.Append(@"{\cf6 ").Append(n).Append("}");
+ }
+
protected virtual void GenerateSourceLocations()
{
sourceLocations = new Dictionary<string, SourceLocation>();
@@ -312,6 +340,7 @@ namespace Microsoft.Boogie.ModelViewer
var currColumn = 1;
var output = new StringBuilder();
var charPos = 0;
+ RtfAppendLineNo(output, currLine, ref charPos);
foreach (var c in content) {
if (c == '\n') {
@@ -320,15 +349,16 @@ namespace Microsoft.Boogie.ModelViewer
while (currPosIdx < positions.Count && positions[currPosIdx].Line <= currLine && positions[currPosIdx].Column <= currColumn) {
positions[currPosIdx].CharPos = charPos;
- SourceLocation.RtfAppendStateIdx(output, positions[currPosIdx].Index.ToString(), ref charPos);
+ RtfAppendStateIdx(output, positions[currPosIdx].Index.ToString(), ref charPos);
currPosIdx++;
}
- SourceLocation.RtfAppend(output, c, ref charPos);
+ RtfAppend(output, c, ref charPos);
if (c == '\n') {
currLine++;
currColumn = 1;
+ RtfAppendLineNo(output, currLine, ref charPos);
} else {
currColumn++;
}
diff --git a/Source/ModelViewer/SourceView.cs b/Source/ModelViewer/SourceView.cs
index 94694260..07c03cd3 100644
--- a/Source/ModelViewer/SourceView.cs
+++ b/Source/ModelViewer/SourceView.cs
@@ -20,7 +20,7 @@ namespace Microsoft.Boogie.ModelViewer
string prefix =
@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Lucida Sans Typewriter;}}\r\n" +
- @"{\colortbl;\red0\green0\blue0;\red255\green0\blue0;\red0\green255\blue0;\red0\green0\blue255;\red255\green255\blue255;}" +
+ @"{\colortbl;\red0\green0\blue0;\red255\green0\blue0;\red0\green255\blue0;\red0\green0\blue255;\red255\green255\blue255;\red100\green100\blue100;}" +
@"\viewkind4\uc1\pard\f0\fs17 ";
internal void SetSourceLocation(SourceLocation r)