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);
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)
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;
98 activeBtn.checked = true;
99 activeBtn.font = { $"Tahoma", 8.25f, bold = true };
100 if(buildBtn != activeBtn) buildBtn.font = null;
101 if(debugBtn != activeBtn) debugBtn.font = null;
102 if(findBtn != activeBtn) findBtn.font = null;
103 #ifdef GDB_DEBUG_OUTPUT
104 if(gdbBtn != activeBtn) gdbBtn.font = null;
107 activeBox.visible = false;
108 activeBtn.Activate(); // Ensure proper cycling (until tab order?)
109 activeBox.visible = true;
110 activeBox.Activate();
111 findDialog.editBox = activeBox;
118 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
119 readOnly = true, hasVertScroll = true, hasHorzScroll = true;
120 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
121 font = { panelFont.faceName, panelFont.size };
122 background = outputBackground;
123 foreground = outputText;
124 selectionColor = selectionColor, selectionText = selectionText;
126 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
128 OnGotoError(editBox.line.text);
129 return false; //true; // why not use true here?
132 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
134 if((SmartKey)key == enter)
136 OnGotoError(editBox.line.text);
145 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
146 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
147 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
148 font = { panelFont.faceName, panelFont.size };
149 background = outputBackground;
150 foreground = outputText;
151 selectionColor = selectionColor, selectionText = selectionText;
156 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
157 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
158 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
159 font = { panelFont.faceName, panelFont.size };
160 background = outputBackground;
161 foreground = outputText;
162 selectionColor = selectionColor, selectionText = selectionText;
164 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
166 OnCodeLocationParseAndGoTo(editBox.line.text);
167 return false; //true;
170 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
172 if((SmartKey)key == enter)
174 OnCodeLocationParseAndGoTo(editBox.line.text);
181 #ifdef GDB_DEBUG_OUTPUT
184 parent = this, freeCaret = true, autoEmpty = true, multiLine = true;
185 readOnly = true, hasVertScroll = true, hasHorzScroll = true, visible = false;
186 anchor = Anchor { left = 0, right = 0, top = 23, bottom = 0 };
187 font = { panelFont.faceName, panelFont.size };
191 Menu editMenu { menu, $"Edit", e };
196 editMenu, $"Copy", c, ctrlC;
197 bool NotifySelect(MenuItem selection, Modifiers mods)
203 MenuDivider { editMenu };
204 MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
205 MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
206 MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
208 bool MenuEditFind(MenuItem selection, Modifiers mods)
210 int64 id = selection.id;
211 char * searchString = findDialog.searchString;
212 if(id != 2 && searchString[0])
214 activeBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, (bool)id);
226 void ShowClearSelectTab(OutputViewTab tab)
231 else if(tab == debug)
237 #ifdef GDB_DEBUG_OUTPUT
244 bool OnKeyDown(Key key, unichar ch)
250 OutputViewTab switchTo;
251 if(activeBox == buildBox)
252 #ifdef GDB_DEBUG_OUTPUT
257 else if(activeBox == debugBox)
259 else if(activeBox == findBox)
261 #ifdef GDB_DEBUG_OUTPUT
262 else if(activeBox == gdbBox)
270 OutputViewTab switchTo;
271 if(activeBox == buildBox)
273 else if(activeBox == debugBox)
275 else if(activeBox == findBox)
276 #ifdef GDB_DEBUG_OUTPUT
278 else if(activeBox == gdbBox)
289 class LogBox : EditBox
291 bool moved, logging, tell;
293 void Logf(char * format, ...)
295 char string[MAX_F_STRING*10];
297 va_start(args, format);
298 vsnprintf(string, sizeof(string), format, args);
299 string[sizeof(string)-1] = 0;
305 void LogSprintf(char * entry)
307 char string[MAX_F_STRING];
308 sprintf(string, entry);
312 void LogRaw(char * entry)
314 // Cut the line longer than 1024 because Logf prints to a buffer (and we don't want to output crazy long lines either)
315 //if(len > 1023) line[1023] = '\0';
316 int len = strlen(entry);
320 char * newStart, * start = entry;
324 newStart = start + 1020;
325 strncpy(backup, newStart, 4);
326 strncpy(newStart, " \\ \0", 4);
328 strncpy(newStart, backup, 4);
333 //while((len = strlen(start)) > 1023)
340 void Log(char * string)
349 GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
363 SetSelPos(line1, y1, x1, line2, y2, x2);
368 void Tellf(char * format, ...)
370 char string[MAX_F_STRING*10];
372 va_start(args, format);
373 vsnprintf(string, sizeof(string), format, args);
374 string[sizeof(string)-1] = 0;
380 void Tell(char * string)
386 GetCaretPosition(caretPos);
387 SetCaret(0, caretPos.y, GetCaretSize());
398 void NotifyCaretMove(EditBox editBox, int line, int charPos)
400 LogBox logBox = (LogBox)editBox;
404 logBox.GetSelPos(null, &y1, null, null, &y2, null, false);
405 logBox.moved = (y1 == logBox.numLines - 1 && y2 == y1) ? false : true;