3 class WatchesView : Window
8 background = { 224, 224, 224 };
10 anchor = Anchor { left = 0, right = 0, bottom = 0 };
17 parent = this, hasHeader = true, hasVertScroll = true, alwaysEdit = true, collapseControl = true, resizable = true;
18 anchor = Anchor { left = 0, right = 0, top = 0, bottom = 0 };
19 background = viewsBackground;
20 foreground = viewsText;
21 selectionColor = selectionColor, selectionText = selectionText;
23 bool NotifyChanged(ListBox listBox, DataRow row)
25 char * expression = row.GetData(expressionField);
27 if(expression && expression[0])
29 TrimLSpaces(expression, expression);
30 TrimRSpaces(expression, expression);
33 if(expression && expression[0])
35 row.SetData(valueField, null);
36 if(row == listBox.lastRow)
38 DataRow newRow = listBox.AddRow();
39 newRow.SetData(expressionField, null);
40 newRow.SetData(valueField, null);
41 listBox.currentRow = newRow;
43 ide.debugger.ChangeWatch(row, expression);
47 ide.debugger.ChangeWatch(row, expression);
48 if(row != listBox.lastRow)
50 //Type type = (Type)row.GetData(typeField);
51 //if(type) FreeType(type);
52 listBox.DeleteRow(row);
55 row.SetData(valueField, null);
60 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
62 if((SmartKey)key == del)
64 listBox.StopEditing(true);
65 if(row && row != listBox.lastRow)
67 //Type type = (Type)row.GetData(typeField);
68 ide.debugger.ChangeWatch(row, null);
69 //if(type) FreeType(type);
70 listBox.DeleteRow(null);
76 DataField expressionField { "char *", true, width = 130, header = $"Expression" };
77 DataField typeField { "Type", false, width = 180, header = $"Type" };
78 //DataField addressField { "char *", true, width = 80, header = $"Symbol Address" };
79 DataField valueField { class(WatchMultiLineString), true, width = 330, header = $"Value", freeData = false };
83 listBox.AddField(expressionField);
84 listBox.AddField(typeField);
85 listBox.AddField(valueField);
88 bool OnKeyDown(Key key, unichar ch)
92 case escape: ide.ShowCodeEditor(); break;
97 bool OnClose(bool parentClosing)
101 ide.RepositionWindows(false);
102 return parentClosing;
108 ide.RepositionWindows(false);
112 void LoadFromWorkspace()
114 for(wh : ide.workspace.watches)
118 void AddWatch(Watch wh)
120 DataRow row = listBox.AddRowAfter(listBox.lastRow.previous);
126 void UpdateWatch(Watch wh)
130 DataRow row = wh.row;
133 row.SetData(expressionField, wh.expression);
134 row.SetData(typeField, wh.type);
135 //row.SetData(addressField, wh.address);
136 row.SetData(valueField, wh.value);
145 row = listBox.AddRow();
146 row.SetData(expressionField, null);
147 row.SetData(typeField, null);
148 row.SetData(valueField, null);
151 for(w : ide.workspace.watches)
157 class WatchMultiLineString : String
159 Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
161 if(this && strchr(this, '\n'))
163 // Don't show the editbox right away so that the text is highlighted by default
166 parent = dataBox, master = obsolete, visible = false,
167 borderStyle = contour,
169 hasHorzScroll = true, hasVertScroll = true,
170 modifyVirtualArea = false,
171 anchor = { 0, 0, 0, 0 };
172 //position = { x + dataBox.absPosition.x, y + dataBox.absPosition.y };
173 //size = { w, h * 4 };
176 bool OnKeyDown(Key key, unichar ch)
180 ((ListBox)master.master).currentField = ((ListBox)master.master).firstField;
183 return EditBox::OnKeyDown(key, ch);
186 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
188 if(active) SelectAll(); else Deselect();
189 return EditBox::OnActivate(active, previous, goOnWithActivation, direct);
192 void DataBox::NotifyUpdate(EditBox editBox)
198 dataBox.size = { w, h * 4 + 2 };
199 if(dataBox.size.h + dataBox.position.y > dataBox.parent.clientSize.h)
200 dataBox.position.y = dataBox.parent.clientSize.h - dataBox.size.h;
201 if(dataBox.size.w + dataBox.position.x > dataBox.parent.clientSize.w)
202 dataBox.position.x = dataBox.parent.clientSize.w - dataBox.size.w;
204 editBox.contents = this;
205 editBox.visible = true;
215 return String::OnEdit(dataBox, obsolete, x, y, w,h, userData);
218 bool OnSaveEdit(Window window, void * object)
220 bool changed = false;
221 EditBox editBox = (EditBox)window;
222 if(editBox.modifiedDocument)
231 for(line = editBox.firstLine; line; line = line.next)
232 size += line.count+1;
233 this = string = new char[size+1];
235 for(line = editBox.firstLine; line; line = line.next)
237 memcpy(string + size, line.text, line.count);
249 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
254 char * string = this;
255 char actualString[8196];
257 for(c = 0; (ch = string[c]) && len < sizeof(actualString)-1; c++)
259 if(ch == '\t') { actualString[len++] = '\\'; actualString[len++] = 't'; }
260 else if(ch == '\r') { actualString[len++] = '\\'; actualString[len++] = 'r'; }
261 else if(ch == '\n') { actualString[len++] = '\\'; actualString[len++] = 'n'; }
262 else actualString[len++] = ch;
264 actualString[len] = 0;
265 ((void (*)(void *, void *, void *, int, int, int, void *, uint, uint))(void *)class(String)._vTbl[__ecereVMethodID_class_OnDisplay])(class(String), actualString, surface, x, y, width, null, alignment, displayFlags);