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 = colorScheme.viewsBackground;
24 foreground = colorScheme.viewsText;
25 selectionColor = colorScheme.selectionColor;
26 selectionText = colorScheme.selectionText;
29 bool NotifyChanged(ListBox listBox, DataRow row)
31 if(listBox.currentField == locationField)
33 char * location = (char *)row.GetData(locationField);
34 if(location && location[0])
36 TrimLSpaces(location, location);
37 TrimRSpaces(location, location);
39 if(location && location[0])
41 if(row == listBox.lastRow)
43 DataRow newRow = listBox.AddRow();
44 newRow.SetData(locationField, null);
46 ide.workspace.ChangeBreakpoint(row, location); // TODO make sure passing only unix style path
50 ide.workspace.RemoveBreakpoint((Breakpoint)(intptr)row.tag);
51 // This is already done by Workspace::RemoveBreakpoint!
52 // listBox.DeleteRow(null);
55 else if(listBox.currentField == ignoreField || listBox.currentField == levelField)
58 char * string = (char *)row.GetData(listBox.currentField);
60 if(string && string[0])
62 TrimLSpaces(string, string);
63 TrimRSpaces(string, string);
66 else if(listBox.currentField == levelField)
69 //sprintf(str, "%d", value);
70 //listBox.StopEditing(true);
71 //row.SetData(listBox.currentField, str);
72 if((listBox.currentField == ignoreField && value < 1) ||
73 (listBox.currentField == levelField && value < 0))
74 row.SetData(listBox.currentField, null);
75 if(listBox.currentField == levelField && value == 0)
76 row.SetData(listBox.currentField, "0");
77 if(listBox.currentField == ignoreField)
78 ide.workspace.ChangeBreakpointIgnore(row, value);
79 else if(listBox.currentField == levelField)
80 ide.workspace.ChangeBreakpointLevel(row, value);
82 else if(listBox.currentField == conditionField)
84 char * condition = (char *)row.GetData(conditionField);
85 if(condition && condition[0])
87 TrimLSpaces(condition, condition);
88 TrimRSpaces(condition, condition);
90 ide.workspace.ChangeBreakpointCondition(row, (condition && condition[0]) ? condition : null);
95 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
97 if((SmartKey)key == enter)
98 GoToBpLocation(listBox.currentRow);
102 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
104 if(row && (SmartKey)key == del)
106 listBox.StopEditing(true);
107 ide.workspace.RemoveBreakpoint((Breakpoint)(intptr)row.tag);
112 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
114 GoToBpLocation(listBox.currentRow);
119 // TODO: set field size based on font and i18n header string
120 // TODO: save column widths to ide settings
121 DataField locationField { "char *", true , width = 220, header = $"Location" };
122 DataField hitsField { "int" , false, width = 28, header = $"Hits" };
123 DataField breaksField { "int" , false, width = 46, header = $"Breaks" };
124 DataField ignoreField { "char *", true , width = 80, header = $"Ignore Count" };
125 DataField levelField { "char *", true , width = 74, header = $"Stack Depth" };
126 DataField conditionField { "char *", true , width = 130, header = $"Condition" };
130 listBox.AddField(locationField);
131 listBox.AddField(hitsField);
132 listBox.AddField(breaksField);
133 listBox.AddField(ignoreField);
134 listBox.AddField(levelField);
135 listBox.AddField(conditionField);
138 bool OnKeyDown(Key key, unichar ch)
142 case escape: ide.ShowCodeEditor(); break;
147 bool OnClose(bool parentClosing)
151 ide.RepositionWindows(false);
152 return parentClosing;
155 void OnRedraw(Surface surface)
158 int lineActive, lineUser;
160 //int scrollY = listBox.scroll.y;
161 //int boxH = clientSize.h;
163 displaySystem.FontExtent(listBox.font.font, " ", 1, null, &lineH);
164 //Window::OnRedraw(surface);
165 ide.debugger.GetCallStackCursorLine(&error, &lineActive, &lineUser);
166 // todo DrawLineMarginIcon(surface, error ? ide.bmpErrorActiveCursor : ide.bmpActiveCursor, lineActive, lineH, scrollY, boxH);
169 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
174 lineY = (line - 1) * lineH;
175 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
177 Bitmap bitmap = resource.bitmap;
179 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
187 ide.RepositionWindows(false);
191 void LoadFromWorkspace()
193 for(bp : ide.workspace.breakpoints; bp.type == user)
197 void AddBreakpoint(Breakpoint bp)
199 DataRow row = listBox.AddRow();
200 row.tag = (int64)(intptr)bp;
202 UpdateBreakpoint(row);
203 ide.callStackView.Update(null);
206 void RemoveBreakpoint(Breakpoint bp)
208 listBox.DeleteRow(bp.row);
210 ide.callStackView.Update(null);
214 void UpdateBreakpoint(DataRow row)
220 Breakpoint bp = (Breakpoint)(intptr)row.tag;
221 location = bp.CopyUserLocationString();
222 #if defined(__WIN32__)
223 ChangeCh(location, '/', '\\');
225 row.SetData(locationField, location);
230 sprintf(string, "%d", bp.ignore);
231 row.SetData(ignoreField, string);
235 sprintf(string, "%d", bp.level);
236 row.SetData(levelField, string);
238 row.SetData(conditionField, bp.condition.expression);
240 row.SetData(conditionField, null);
241 row.SetData(hitsField, bp.hits);
242 row.SetData(breaksField, bp.breaks);
252 void GoToBpLocation(DataRow row)
256 char * location = (char *)row.GetData(locationField);
258 ide.debugger.GoToCodeLine(location);