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(const char * line, bool noParsing);
25 virtual void OnCodeLocationParseAndGoTo(const 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 };
125 font = { panelFont.faceName, panelFont.size, panelFont.bold, panelFont.italic };
126 background = colorScheme.outputBackground;
127 foreground = colorScheme.outputText;
128 selectionColor = colorScheme.selectionColor;
129 selectionText = colorScheme.selectionText;
132 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
134 OnGotoError(editBox.line.text, mods.ctrl && mods.shift);
138 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
140 if(key.code == enter || key.code == keyPadEnter)
142 OnGotoError(editBox.line.text, key.ctrl && key.shift);
151 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
152 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
153 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
155 font = { panelFont.faceName, panelFont.size, panelFont.bold, panelFont.italic };
156 background = colorScheme.outputBackground;
157 foreground = colorScheme.outputText;
158 selectionColor = colorScheme.selectionColor;
159 selectionText = colorScheme.selectionText;
162 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
164 OnCodeLocationParseAndGoTo(editBox.line.text);
168 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
170 if((SmartKey)key == enter)
172 OnCodeLocationParseAndGoTo(editBox.line.text);
181 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
182 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
183 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
185 font = { panelFont.faceName, panelFont.size, panelFont.bold, panelFont.italic };
186 background = colorScheme.outputBackground;
187 foreground = colorScheme.outputText;
188 selectionColor = colorScheme.selectionColor;
189 selectionText = colorScheme.selectionText;
192 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
194 OnCodeLocationParseAndGoTo(editBox.line.text);
198 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
200 if((SmartKey)key == enter)
202 OnCodeLocationParseAndGoTo(editBox.line.text);
209 #ifdef GDB_DEBUG_OUTPUT
212 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
213 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
214 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
215 font = { panelFont.faceName, panelFont.size, panelFont.bold, panelFont.italic };
216 background = colorScheme.outputBackground;
217 foreground = colorScheme.outputText;
218 selectionColor = colorScheme.selectionColor;
219 selectionText = colorScheme.selectionText;
223 Menu editMenu { menu, $"Edit", e };
228 editMenu, $"Copy", c, ctrlC;
229 bool NotifySelect(MenuItem selection, Modifiers mods)
235 MenuDivider { editMenu };
236 MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
237 MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
238 MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
240 bool MenuEditFind(MenuItem selection, Modifiers mods)
242 int64 id = selection.id;
243 const char * searchString = findDialog.searchString;
244 if(id != 2 && searchString[0])
246 activeBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, id != 0);
256 ide.RepositionWindows(false);
259 void ShowClearSelectTab(OutputViewTab tab)
264 else if(tab == debug)
270 #ifdef GDB_DEBUG_OUTPUT
277 bool OnKeyDown(Key key, unichar ch)
283 OutputViewTab switchTo = build;
284 if(activeBox == buildBox)
285 #ifdef GDB_DEBUG_OUTPUT
290 else if(activeBox == debugBox)
292 else if(activeBox == findBox)
294 #ifdef GDB_DEBUG_OUTPUT
295 else if(activeBox == gdbBox)
303 OutputViewTab switchTo = debug;
304 if(activeBox == buildBox)
306 else if(activeBox == debugBox)
308 else if(activeBox == findBox)
309 #ifdef GDB_DEBUG_OUTPUT
311 else if(activeBox == gdbBox)
322 class LogBox : EditBox
324 bool moved, logging, tell;
326 void Logf(const char * format, ...)
328 char string[MAX_F_STRING*10];
330 va_start(args, format);
331 vsnprintf(string, sizeof(string), format, args);
332 string[sizeof(string)-1] = 0;
338 void LogRaw(const char * entry)
340 // Cut the line longer than 1024 because Logf prints to a buffer (and we don't want to output crazy long lines either)
341 //if(len > 1023) line[1023] = '\0';
342 /* Fixed, but disabled this ... Not sure if there's any reason to keep it? The EditBox should be fine with long lines
343 and it's easier to copy commands and go to errors */
344 /*int len = strlen(entry);
347 char * newStart, * start = entry;
352 newStart = start + 1020;
353 strncpy(backup, newStart, 3);
354 strncpy(newStart, "\n ", 3);
356 strncpy(newStart, backup, 3);
366 void Log(const char * string)
375 GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
389 SetSelPos(line1, y1, x1, line2, y2, x2);
394 void Tellf(const char * format, ...)
396 char string[MAX_F_STRING*10];
398 va_start(args, format);
399 vsnprintf(string, sizeof(string), format, args);
400 string[sizeof(string)-1] = 0;
406 void Tell(const char * string)
412 GetCaretPosition(caretPos);
413 SetCaret(0, caretPos.y, GetCaretSize());
424 void NotifyCaretMove(EditBox editBox, int line, int charPos)
426 LogBox logBox = (LogBox)editBox;
430 logBox.GetSelPos(null, &y1, null, null, &y2, null, false);
431 logBox.moved = (y1 == logBox.numLines - 1 && y2 == y1) ? false : true;