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 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
78 if(listBox.currentField != expressionField)
79 listBox.currentField = expressionField;
83 DataField expressionField { "char *", true, width = 130, header = $"Expression" };
84 DataField typeField { "Type", false, width = 180, header = $"Type" };
85 //DataField addressField { "char *", true, width = 80, header = $"Symbol Address" };
86 DataField valueField { class(WatchMultiLineString), true, width = 330, header = $"Value", freeData = false };
90 listBox.AddField(expressionField);
91 listBox.AddField(typeField);
92 listBox.AddField(valueField);
95 bool OnKeyDown(Key key, unichar ch)
99 case escape: ide.ShowCodeEditor(); break;
104 bool OnClose(bool parentClosing)
108 ide.RepositionWindows(false);
109 return parentClosing;
115 ide.RepositionWindows(false);
119 void LoadFromWorkspace()
121 for(wh : ide.workspace.watches)
125 void AddWatch(Watch wh)
127 DataRow row = listBox.AddRowAfter(listBox.lastRow.previous);
133 void UpdateWatch(Watch wh)
137 DataRow row = wh.row;
140 row.SetData(expressionField, wh.expression);
141 row.SetData(typeField, wh.type);
142 //row.SetData(addressField, wh.address);
143 row.SetData(valueField, wh.value);
152 row = listBox.AddRow();
153 row.SetData(expressionField, null);
154 row.SetData(typeField, null);
155 row.SetData(valueField, null);
158 for(w : ide.workspace.watches)
164 class WatchMultiLineString : String
166 Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
168 if(this && strchr(this, '\n'))
170 // Don't show the editbox right away so that the text is highlighted by default
173 parent = dataBox, master = obsolete, visible = false,
174 borderStyle = contour,
176 hasHorzScroll = true, hasVertScroll = true,
177 modifyVirtualArea = false,
178 anchor = { 0, 0, 0, 0 };
179 //position = { x + dataBox.absPosition.x, y + dataBox.absPosition.y };
180 //size = { w, h * 4 };
183 bool OnKeyDown(Key key, unichar ch)
187 ((ListBox)master.master).currentField = ((ListBox)master.master).firstField;
190 return EditBox::OnKeyDown(key, ch);
193 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
195 if(active) SelectAll(); else Deselect();
196 return EditBox::OnActivate(active, previous, goOnWithActivation, direct);
199 void DataBox::NotifyUpdate(EditBox editBox)
205 dataBox.size = { w, h * 4 + 2 };
206 if(dataBox.size.h + dataBox.position.y > dataBox.parent.clientSize.h)
207 dataBox.position.y = dataBox.parent.clientSize.h - dataBox.size.h;
208 if(dataBox.size.w + dataBox.position.x > dataBox.parent.clientSize.w)
209 dataBox.position.x = dataBox.parent.clientSize.w - dataBox.size.w;
211 editBox.contents = this;
212 editBox.visible = true;
222 return String::OnEdit(dataBox, obsolete, x, y, w,h, userData);
225 bool OnSaveEdit(Window window, void * object)
227 bool changed = false;
228 EditBox editBox = (EditBox)window;
229 if(editBox.modifiedDocument)
238 for(line = editBox.firstLine; line; line = line.next)
239 size += line.count+1;
240 this = string = new char[size+1];
242 for(line = editBox.firstLine; line; line = line.next)
244 memcpy(string + size, line.text, line.count);
256 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
261 char * string = this;
262 char actualString[8196];
264 for(c = 0; (ch = string[c]) && len < sizeof(actualString)-1; c++)
266 if(ch == '\t') { actualString[len++] = '\\'; actualString[len++] = 't'; }
267 else if(ch == '\r') { actualString[len++] = '\\'; actualString[len++] = 'r'; }
268 else if(ch == '\n') { actualString[len++] = '\\'; actualString[len++] = 'n'; }
269 else actualString[len++] = ch;
271 actualString[len] = 0;
272 ((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);