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 };
124 font = { panelFont.faceName, panelFont.size, panelFont.bold, panelFont.italic };
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, panelFont.bold, panelFont.italic };
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, panelFont.bold, panelFont.italic };
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, panelFont.bold, panelFont.italic };
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 const char * searchString = findDialog.searchString;
234 if(id != 2 && searchString[0])
236 activeBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, id != 0);
246 ide.RepositionWindows(false);
249 void ShowClearSelectTab(OutputViewTab tab)
254 else if(tab == debug)
260 #ifdef GDB_DEBUG_OUTPUT
267 bool OnKeyDown(Key key, unichar ch)
273 OutputViewTab switchTo = build;
274 if(activeBox == buildBox)
275 #ifdef GDB_DEBUG_OUTPUT
280 else if(activeBox == debugBox)
282 else if(activeBox == findBox)
284 #ifdef GDB_DEBUG_OUTPUT
285 else if(activeBox == gdbBox)
293 OutputViewTab switchTo = debug;
294 if(activeBox == buildBox)
296 else if(activeBox == debugBox)
298 else if(activeBox == findBox)
299 #ifdef GDB_DEBUG_OUTPUT
301 else if(activeBox == gdbBox)
312 class LogBox : EditBox
314 bool moved, logging, tell;
316 void Logf(const char * format, ...)
318 char string[MAX_F_STRING*10];
320 va_start(args, format);
321 vsnprintf(string, sizeof(string), format, args);
322 string[sizeof(string)-1] = 0;
328 void LogRaw(const char * entry)
330 // Cut the line longer than 1024 because Logf prints to a buffer (and we don't want to output crazy long lines either)
331 //if(len > 1023) line[1023] = '\0';
332 /* Fixed, but disabled this ... Not sure if there's any reason to keep it? The EditBox should be fine with long lines
333 and it's easier to copy commands and go to errors */
334 /*int len = strlen(entry);
337 char * newStart, * start = entry;
342 newStart = start + 1020;
343 strncpy(backup, newStart, 3);
344 strncpy(newStart, "\n ", 3);
346 strncpy(newStart, backup, 3);
356 void Log(const char * string)
365 GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
379 SetSelPos(line1, y1, x1, line2, y2, x2);
384 void Tellf(const char * format, ...)
386 char string[MAX_F_STRING*10];
388 va_start(args, format);
389 vsnprintf(string, sizeof(string), format, args);
390 string[sizeof(string)-1] = 0;
396 void Tell(const char * string)
402 GetCaretPosition(caretPos);
403 SetCaret(0, caretPos.y, GetCaretSize());
414 void NotifyCaretMove(EditBox editBox, int line, int charPos)
416 LogBox logBox = (LogBox)editBox;
420 logBox.GetSelPos(null, &y1, null, null, &y2, null, false);
421 logBox.moved = (y1 == logBox.numLines - 1 && y2 == y1) ? false : true;