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);
132 return false; //true; // why not use true here?
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;
159 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
160 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
161 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
162 font = { panelFont.faceName, panelFont.size };
163 background = outputBackground;
164 foreground = outputText;
165 selectionColor = selectionColor, selectionText = selectionText;
167 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
169 OnCodeLocationParseAndGoTo(editBox.line.text);
170 return false; //true;
173 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
175 if((SmartKey)key == enter)
177 OnCodeLocationParseAndGoTo(editBox.line.text);
184 #ifdef GDB_DEBUG_OUTPUT
187 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
188 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
189 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
190 font = { panelFont.faceName, panelFont.size };
194 Menu editMenu { menu, $"Edit", e };
199 editMenu, $"Copy", c, ctrlC;
200 bool NotifySelect(MenuItem selection, Modifiers mods)
206 MenuDivider { editMenu };
207 MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
208 MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
209 MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
211 bool MenuEditFind(MenuItem selection, Modifiers mods)
213 int64 id = selection.id;
214 char * searchString = findDialog.searchString;
215 if(id != 2 && searchString[0])
217 activeBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, (bool)id);
229 void ShowClearSelectTab(OutputViewTab tab)
234 else if(tab == debug)
240 #ifdef GDB_DEBUG_OUTPUT
247 bool OnKeyDown(Key key, unichar ch)
253 OutputViewTab switchTo;
254 if(activeBox == buildBox)
255 #ifdef GDB_DEBUG_OUTPUT
260 else if(activeBox == debugBox)
262 else if(activeBox == findBox)
264 #ifdef GDB_DEBUG_OUTPUT
265 else if(activeBox == gdbBox)
273 OutputViewTab switchTo = debug;
274 if(activeBox == buildBox)
276 else if(activeBox == debugBox)
278 else if(activeBox == findBox)
279 #ifdef GDB_DEBUG_OUTPUT
281 else if(activeBox == gdbBox)
292 class LogBox : EditBox
294 bool moved, logging, tell;
296 void Logf(char * format, ...)
298 char string[MAX_F_STRING*10];
300 va_start(args, format);
301 vsnprintf(string, sizeof(string), format, args);
302 string[sizeof(string)-1] = 0;
308 void LogSprintf(char * entry)
310 char string[MAX_F_STRING];
311 sprintf(string, entry);
315 void LogRaw(char * entry)
317 // Cut the line longer than 1024 because Logf prints to a buffer (and we don't want to output crazy long lines either)
318 //if(len > 1023) line[1023] = '\0';
319 /* Fixed, but disabled this ... Not sure if there's any reason to keep it? The EditBox should be fine with long lines
320 and it's easier to copy commands and go to errors */
321 /*int len = strlen(entry);
324 char * newStart, * start = entry;
329 newStart = start + 1020;
330 strncpy(backup, newStart, 3);
331 strncpy(newStart, "\n ", 3);
333 strncpy(newStart, backup, 3);
343 void Log(char * string)
352 GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
366 SetSelPos(line1, y1, x1, line2, y2, x2);
371 void Tellf(char * format, ...)
373 char string[MAX_F_STRING*10];
375 va_start(args, format);
376 vsnprintf(string, sizeof(string), format, args);
377 string[sizeof(string)-1] = 0;
383 void Tell(char * string)
389 GetCaretPosition(caretPos);
390 SetCaret(0, caretPos.y, GetCaretSize());
401 void NotifyCaretMove(EditBox editBox, int line, int charPos)
403 LogBox logBox = (LogBox)editBox;
407 logBox.GetSelPos(null, &y1, null, null, &y2, null, false);
408 logBox.moved = (y1 == logBox.numLines - 1 && y2 == y1) ? false : true;