6 class ThreadsView : Window
9 borderStyle = sizableDeep;
10 background = { 224, 224, 224 };
16 anchor = Anchor { left = 0.8, right = 0, top = 0 };
20 FindDialog findDialog { master = this, editBox = editBox, isModal = true, autoCreate = false, text = "Find" };
22 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
23 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
24 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
25 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
27 virtual void OnSelectThread(int threadId);
28 virtual bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread);
32 return atoi(editBox.line.text);
35 int FindThreadId(int threadId)
39 for(line = editBox.firstLine, lineNumber = 1; line; line = line.next, lineNumber++)
41 int id = atoi(line.text);
42 if(id && id == threadId)
50 parent = this, freeCaret = true, autoEmpty = true, multiLine = true, readOnly = true;
51 hasVertScroll = true, hasHorzScroll = true, borderStyle = none;
52 anchor = { left = 20, right = 0, top = 0, bottom = 0 };
54 background = colorScheme.viewsBackground;
55 foreground = colorScheme.viewsText;
56 selectionColor = colorScheme.selectionColor;
57 selectionText = colorScheme.selectionText;
60 bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
62 int id = GetThreadId();
67 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
69 if((SmartKey)key == enter)
71 int id = GetThreadId();
78 void NotifyCaretMove(EditBox editBox, int line, int charPos)
83 editBox.GetSelPos(null, &y1, null, null, &y2, null, false);
84 moved = (y1 == editBox.numLines - 1 && y2 == y1) ? false : true;
88 void OnVScroll(ScrollBarAction action, int position, Key key)
90 int boxH = clientSize.h;
91 Box box = { 0,0, 19, boxH - 1 };
93 EditBox::OnVScroll(action, position, key);
98 Menu editMenu { menu, $"Edit", e };
103 editMenu, $"Copy", c, ctrlC;
104 bool NotifySelect(MenuItem selection, Modifiers mods)
110 MenuDivider { editMenu };
111 MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
112 MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
113 MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
115 bool MenuEditFind(MenuItem selection, Modifiers mods)
117 int64 id = selection.id;
118 const char * searchString = findDialog.searchString;
119 if(id != 2 && searchString[0])
121 editBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, id != 0);
128 void Logf(const char * format, ...)
130 char string[MAX_F_STRING*10];
132 va_start(args, format);
133 vsnprintf(string, sizeof(string), format, args);
134 string[sizeof(string)-1] = 0;
140 void LogRaw(const char * entry)
144 void Log(const char * string)
153 editBox.GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
154 scroll = editBox.scroll;
157 editBox.PutS(string);
158 editBox.Update(null);
161 editBox.scroll = scroll;
162 editBox.SetSelPos(line1, y1, x1, line2, y2, x2);
178 ide.RepositionWindows(false);
182 void OnRedraw(Surface surface)
185 int scrollY = editBox.scroll.y;
186 int boxH = clientSize.h;
188 int activeThread, hitThread, signalThread;
190 if(OnGetThreadsInfo(&activeThread, &hitThread, &signalThread))
193 BitmapResource bmpRes;
194 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
195 for(line = editBox.firstLine, lineNumber = 1; line; line = line.next, lineNumber++)
197 if(strlen(line.text))
199 int id = atoi(line.text);
200 bmpRes = (id == signalThread) ? bmpTopFrameError : bmpTopFrame;
201 if(id == activeThread)
203 DrawLineMarginIcon(surface,
204 (id == signalThread) ? bmpCursorError : bmpCursor,
205 lineNumber, lineH, scrollY, boxH);
207 else if(id == signalThread)
208 DrawLineMarginIcon(surface, bmpRes, lineNumber, lineH, scrollY, boxH);
211 if(editBox.horzScroll && editBox.horzScroll.visible)
213 surface.SetBackground(control);
214 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
219 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
224 lineY = (line - 1) * lineH;
225 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
227 Bitmap bitmap = resource.bitmap;
229 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);