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 };
20 background = colorScheme.viewsBackground;
21 foreground = colorScheme.viewsText;
22 selectionColor = colorScheme.selectionColor;
23 selectionText = colorScheme.selectionText;
26 bool NotifyChanged(ListBox listBox, DataRow row)
28 char * expression = row.GetData(expressionField);
30 if(expression && expression[0])
32 TrimLSpaces(expression, expression);
33 TrimRSpaces(expression, expression);
36 if(expression && expression[0])
38 row.SetData(valueField, null);
39 if(row == listBox.lastRow)
41 DataRow newRow = listBox.AddRow();
42 newRow.SetData(expressionField, null);
43 newRow.SetData(valueField, null);
44 listBox.currentRow = newRow;
46 ide.debugger.ChangeWatch(row, expression);
50 ide.debugger.ChangeWatch(row, expression);
51 if(row != listBox.lastRow)
53 //Type type = (Type)row.GetData(typeField);
54 //if(type) FreeType(type);
55 listBox.DeleteRow(row);
58 row.SetData(valueField, null);
63 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
65 if((SmartKey)key == del)
67 listBox.StopEditing(true);
68 if(row && row != listBox.lastRow)
70 //Type type = (Type)row.GetData(typeField);
71 ide.debugger.ChangeWatch(row, null);
72 //if(type) FreeType(type);
73 listBox.DeleteRow(null);
79 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
81 if(listBox.currentField != expressionField)
82 listBox.currentField = expressionField;
86 DataField expressionField { "char *", true, width = 130, header = $"Expression" };
87 DataField typeField { "Type", false, width = 180, header = $"Type" };
88 //DataField addressField { "char *", true, width = 80, header = $"Symbol Address" };
89 DataField valueField { class(WatchMultiLineString), true, width = 330, header = $"Value", freeData = false };
93 listBox.AddField(expressionField);
94 listBox.AddField(typeField);
95 listBox.AddField(valueField);
98 bool OnKeyDown(Key key, unichar ch)
102 case escape: ide.ShowCodeEditor(); break;
107 bool OnClose(bool parentClosing)
111 ide.RepositionWindows(false);
112 return parentClosing;
118 ide.RepositionWindows(false);
122 void LoadFromWorkspace()
124 for(wh : ide.workspace.watches)
128 void AddWatch(Watch wh)
130 DataRow row = listBox.AddRowAfter(listBox.lastRow.previous);
131 row.tag = (int64)(intptr)wh;
136 void UpdateWatch(Watch wh)
140 DataRow row = wh.row;
143 row.SetData(expressionField, wh.expression);
144 row.SetData(typeField, wh.type);
145 //row.SetData(addressField, wh.address);
146 row.SetData(valueField, wh.value);
155 row = listBox.AddRow();
156 row.SetData(expressionField, null);
157 row.SetData(typeField, null);
158 row.SetData(valueField, null);
161 for(w : ide.workspace.watches)
167 class WatchMultiLineString : String
169 Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
171 if(this && strchr(this, '\n'))
173 // Don't show the editbox right away so that the text is highlighted by default
176 parent = dataBox, master = obsolete, visible = false,
177 borderStyle = contour,
179 hasHorzScroll = true, hasVertScroll = true,
180 modifyVirtualArea = false,
181 anchor = { 0, 0, 0, 0 };
182 //position = { x + dataBox.absPosition.x, y + dataBox.absPosition.y };
183 //size = { w, h * 4 };
186 bool OnKeyDown(Key key, unichar ch)
190 ((ListBox)master.master).currentField = ((ListBox)master.master).firstField;
193 return EditBox::OnKeyDown(key, ch);
196 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
198 if(active) SelectAll(); else Deselect();
199 return EditBox::OnActivate(active, previous, goOnWithActivation, direct);
202 void DataBox::NotifyUpdate(EditBox editBox)
208 dataBox.size = { w, h * 4 + 2 };
209 if(dataBox.size.h + dataBox.position.y > dataBox.parent.clientSize.h)
210 dataBox.position.y = dataBox.parent.clientSize.h - dataBox.size.h;
211 if(dataBox.size.w + dataBox.position.x > dataBox.parent.clientSize.w)
212 dataBox.position.x = dataBox.parent.clientSize.w - dataBox.size.w;
214 editBox.contents = this;
215 editBox.visible = true;
225 return String::OnEdit(dataBox, obsolete, x, y, w,h, userData);
228 bool OnSaveEdit(Window window, void * object)
230 bool changed = false;
231 EditBox editBox = (EditBox)window;
232 if(editBox.modifiedDocument)
241 for(line = editBox.firstLine; line; line = line.next)
242 size += line.count+1;
243 this = string = new char[size+1];
245 for(line = editBox.firstLine; line; line = line.next)
247 memcpy(string + size, line.text, line.count);
259 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
264 char * string = this;
265 char actualString[8196];
267 for(c = 0; (ch = string[c]) && len < sizeof(actualString)-1; c++)
269 if(ch == '\t') { actualString[len++] = '\\'; actualString[len++] = 't'; }
270 else if(ch == '\r') { actualString[len++] = '\\'; actualString[len++] = 'r'; }
271 else if(ch == '\n') { actualString[len++] = '\\'; actualString[len++] = 'n'; }
272 else actualString[len++] = ch;
274 actualString[len] = 0;
275 ((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);