3 class BreakpointsView : Window
7 background = { 224, 224, 224 };
10 clientSize = Size { 206, 624 };
11 //anchor = Anchor { left = 0.8, top = 200, right = 0, bottom = 200 };
13 anchor = Anchor { left = 0, right = 0, bottom = 0 };
20 parent = this, resizable = true, hasHeader = true, alwaysEdit = true, collapseControl = true, size = { 206, 624 };
21 anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 }; //visible = true
23 background = viewsBackground;
24 foreground = viewsText;
25 selectionColor = selectionColor, selectionText = selectionText;
27 bool NotifyChanged(ListBox listBox, DataRow row)
29 if(listBox.currentField == locationField)
31 char * location = (char *)row.GetData(locationField);
32 if(location && location[0])
34 TrimLSpaces(location, location);
35 TrimRSpaces(location, location);
37 if(location && location[0])
39 if(row == listBox.lastRow)
41 DataRow newRow = listBox.AddRow();
42 newRow.SetData(locationField, null);
44 ide.workspace.ChangeBreakpoint(row, location); // TODO make sure passing only unix style path
48 ide.workspace.RemoveBreakpoint((Breakpoint)row.tag);
49 // This is already done by Workspace::RemoveBreakpoint!
50 // listBox.DeleteRow(null);
53 else if(listBox.currentField == ignoreField || listBox.currentField == levelField)
56 char * string = (char *)row.GetData(listBox.currentField);
58 if(string && string[0])
60 TrimLSpaces(string, string);
61 TrimRSpaces(string, string);
64 else if(listBox.currentField == levelField)
67 //sprintf(str, "%d", value);
68 //listBox.StopEditing(true);
69 //row.SetData(listBox.currentField, str);
70 if((listBox.currentField == ignoreField && value < 1) ||
71 (listBox.currentField == levelField && value < 0))
72 row.SetData(listBox.currentField, null);
73 if(listBox.currentField == levelField && value == 0)
74 row.SetData(listBox.currentField, "0");
75 if(listBox.currentField == ignoreField)
76 ide.workspace.ChangeBreakpointIgnore(row, value);
77 else if(listBox.currentField == levelField)
78 ide.workspace.ChangeBreakpointLevel(row, value);
80 else if(listBox.currentField == conditionField)
82 char * condition = (char *)row.GetData(conditionField);
83 if(condition && condition[0])
85 TrimLSpaces(condition, condition);
86 TrimRSpaces(condition, condition);
88 ide.workspace.ChangeBreakpointCondition(row, (condition && condition[0]) ? condition : null);
93 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
95 if((SmartKey)key == enter)
96 GoToBpLocation(listBox.currentRow);
100 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
102 if(row && (SmartKey)key == del)
104 listBox.StopEditing(true);
105 ide.workspace.RemoveBreakpoint((Breakpoint)row.tag);
110 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
112 GoToBpLocation(listBox.currentRow);
117 // TODO: set field size based on font and i18n header string
118 // TODO: save column widths to ide settings
119 DataField locationField { "char *", true , width = 220, header = $"Location" };
120 DataField hitsField { "int" , false, width = 28, header = $"Hits" };
121 DataField breaksField { "int" , false, width = 46, header = $"Breaks" };
122 DataField ignoreField { "char *", true , width = 80, header = $"Ignore Count" };
123 DataField levelField { "char *", true , width = 74, header = $"Stack Depth" };
124 DataField conditionField { "char *", true , width = 130, header = $"Condition" };
128 listBox.AddField(locationField);
129 listBox.AddField(hitsField);
130 listBox.AddField(breaksField);
131 listBox.AddField(ignoreField);
132 listBox.AddField(levelField);
133 listBox.AddField(conditionField);
136 bool OnKeyDown(Key key, unichar ch)
140 case escape: ide.ShowCodeEditor(); break;
145 bool OnClose(bool parentClosing)
149 ide.RepositionWindows(false);
150 return parentClosing;
153 void OnRedraw(Surface surface)
156 int lineActive, lineUser;
158 int scrollY = listBox.scroll.y;
159 int boxH = clientSize.h;
161 displaySystem.FontExtent(listBox.font.font, " ", 1, null, &lineH);
162 //Window::OnRedraw(surface);
163 ide.debugger.GetCallStackCursorLine(&error, &lineActive, &lineUser);
164 // todo DrawLineMarginIcon(surface, error ? ide.bmpErrorActiveCursor : ide.bmpActiveCursor, lineActive, lineH, scrollY, boxH);
167 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
172 lineY = (line - 1) * lineH;
173 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
175 Bitmap bitmap = resource.bitmap;
177 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
185 ide.RepositionWindows(false);
189 void LoadFromWorkspace()
191 for(bp : ide.workspace.breakpoints; bp.type == user)
195 void AddBreakpoint(Breakpoint bp)
198 DataRow row = listBox.AddRow();
201 UpdateBreakpoint(row);
202 ide.callStackView.Update(null);
205 void RemoveBreakpoint(Breakpoint bp)
207 listBox.DeleteRow(bp.row);
209 ide.callStackView.Update(null);
213 void UpdateBreakpoint(DataRow row)
219 Breakpoint bp = (Breakpoint)row.tag;
220 location = bp.CopyUserLocationString();
221 #if defined(__WIN32__)
222 ChangeCh(location, '/', '\\');
224 row.SetData(locationField, location);
229 sprintf(string, "%d", bp.ignore);
230 row.SetData(ignoreField, string);
234 sprintf(string, "%d", bp.level);
235 row.SetData(levelField, string);
237 row.SetData(conditionField, bp.condition.expression);
239 row.SetData(conditionField, null);
240 row.SetData(hitsField, bp.hits);
241 row.SetData(breaksField, bp.breaks);
251 void GoToBpLocation(DataRow row)
255 char * location = (char *)row.GetData(locationField);
257 ide.debugger.GoToCodeLine(location);