6 enum OutputViewTab { build, debug, find
7 #ifdef GDB_DEBUG_OUTPUT
12 class OutputView : Window
15 borderStyle = sizable;
20 anchor = Anchor { left = 0, right = 0, bottom = 0 };
22 background = formColor;
24 virtual void OnGotoError(char * line, bool noParsing);
25 virtual void OnCodeLocationParseAndGoTo(char * line);
27 FindDialog findDialog { master = this, editBox = buildBox, isModal = true, autoCreate = false, text = "Find" };
31 this, inactive = true, text = "Build", bevelOver = true, isRadio = true, bitmap = null, checked = true;
33 anchor = { left = 0, top = 1 };
34 font = { $"Tahoma", 8.25f, bold = true };
36 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
45 this, inactive = true, text = "Debug", bevelOver = true, isRadio = true, bitmap = null;
47 anchor = { left = 100, top = 1 };
49 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
58 this, inactive = true, text = "Find", bevelOver = true, isRadio = true, bitmap = null;
60 anchor = { left = 200, top = 1 };
62 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
69 #ifdef GDB_DEBUG_OUTPUT
72 this, inactive = true, text = "GDB", bevelOver = true, isRadio = true, bitmap = null;
74 anchor = { left = 300, top = 1 };
76 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
84 void SelectTab(OutputViewTab tab)
86 Button activeBtn = null;
88 activeBtn = buildBtn, activeBox = buildBox;
90 activeBtn = debugBtn, activeBox = debugBox;
92 activeBtn = findBtn, activeBox = findBox;
93 #ifdef GDB_DEBUG_OUTPUT
95 activeBtn = gdbBtn, activeBox = gdbBox;
97 if(activeBtn && activeBox)
99 activeBtn.checked = true;
100 activeBtn.font = { $"Tahoma", 8.25f, bold = true };
101 if(buildBtn != activeBtn) buildBtn.font = null;
102 if(debugBtn != activeBtn) debugBtn.font = null;
103 if(findBtn != activeBtn) findBtn.font = null;
104 #ifdef GDB_DEBUG_OUTPUT
105 if(gdbBtn != activeBtn) gdbBtn.font = null;
108 activeBox.visible = false;
109 activeBtn.Activate(); // Ensure proper cycling (until tab order?)
110 activeBox.visible = true;
111 activeBox.Activate();
112 findDialog.editBox = activeBox;
117 activeBox = buildBox;
121 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
122 readOnly = true, hasVertScroll = true, hasHorzScroll = true;
123 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
124 font = { panelFont.faceName, panelFont.size };
125 background = outputBackground;
126 foreground = outputText;
127 selectionColor = selectionColor, selectionText = selectionText;
129 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
131 OnGotoError(editBox.line.text, mods.ctrl && mods.shift);
135 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
137 if(key.code == enter || key.code == keyPadEnter)
139 OnGotoError(editBox.line.text, key.ctrl && key.shift);
148 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
149 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
150 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
151 font = { panelFont.faceName, panelFont.size };
152 background = outputBackground;
153 foreground = outputText;
154 selectionColor = selectionColor, selectionText = selectionText;
156 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
158 OnCodeLocationParseAndGoTo(editBox.line.text);
162 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
164 if((SmartKey)key == enter)
166 OnCodeLocationParseAndGoTo(editBox.line.text);
175 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
176 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
177 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
178 font = { panelFont.faceName, panelFont.size };
179 background = outputBackground;
180 foreground = outputText;
181 selectionColor = selectionColor, selectionText = selectionText;
183 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
185 OnCodeLocationParseAndGoTo(editBox.line.text);
189 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
191 if((SmartKey)key == enter)
193 OnCodeLocationParseAndGoTo(editBox.line.text);
200 #ifdef GDB_DEBUG_OUTPUT
203 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
204 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
205 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
206 font = { panelFont.faceName, panelFont.size };
207 background = outputBackground;
208 foreground = outputText;
209 selectionColor = selectionColor, selectionText = selectionText;
213 Menu editMenu { menu, $"Edit", e };
218 editMenu, $"Copy", c, ctrlC;
219 bool NotifySelect(MenuItem selection, Modifiers mods)
225 MenuDivider { editMenu };
226 MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
227 MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
228 MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
230 bool MenuEditFind(MenuItem selection, Modifiers mods)
232 int64 id = selection.id;
233 char * searchString = findDialog.searchString;
234 if(id != 2 && searchString[0])
236 activeBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, (bool)id);
248 void ShowClearSelectTab(OutputViewTab tab)
253 else if(tab == debug)
259 #ifdef GDB_DEBUG_OUTPUT
266 bool OnKeyDown(Key key, unichar ch)
272 OutputViewTab switchTo;
273 if(activeBox == buildBox)
274 #ifdef GDB_DEBUG_OUTPUT
279 else if(activeBox == debugBox)
281 else if(activeBox == findBox)
283 #ifdef GDB_DEBUG_OUTPUT
284 else if(activeBox == gdbBox)
292 OutputViewTab switchTo = debug;
293 if(activeBox == buildBox)
295 else if(activeBox == debugBox)
297 else if(activeBox == findBox)
298 #ifdef GDB_DEBUG_OUTPUT
300 else if(activeBox == gdbBox)
311 class LogBox : EditBox
313 bool moved, logging, tell;
315 void Logf(char * format, ...)
317 char string[MAX_F_STRING*10];
319 va_start(args, format);
320 vsnprintf(string, sizeof(string), format, args);
321 string[sizeof(string)-1] = 0;
327 void LogSprintf(char * entry)
329 char string[MAX_F_STRING];
330 sprintf(string, entry);
334 void LogRaw(char * entry)
336 // Cut the line longer than 1024 because Logf prints to a buffer (and we don't want to output crazy long lines either)
337 //if(len > 1023) line[1023] = '\0';
338 /* Fixed, but disabled this ... Not sure if there's any reason to keep it? The EditBox should be fine with long lines
339 and it's easier to copy commands and go to errors */
340 /*int len = strlen(entry);
343 char * newStart, * start = entry;
348 newStart = start + 1020;
349 strncpy(backup, newStart, 3);
350 strncpy(newStart, "\n ", 3);
352 strncpy(newStart, backup, 3);
362 void Log(char * string)
371 GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
385 SetSelPos(line1, y1, x1, line2, y2, x2);
390 void Tellf(char * format, ...)
392 char string[MAX_F_STRING*10];
394 va_start(args, format);
395 vsnprintf(string, sizeof(string), format, args);
396 string[sizeof(string)-1] = 0;
402 void Tell(char * string)
408 GetCaretPosition(caretPos);
409 SetCaret(0, caretPos.y, GetCaretSize());
420 void NotifyCaretMove(EditBox editBox, int line, int charPos)
422 LogBox logBox = (LogBox)editBox;
426 logBox.GetSelPos(null, &y1, null, null, &y2, null, false);
427 logBox.moved = (y1 == logBox.numLines - 1 && y2 == y1) ? false : true;