cleaned all trailing white space from source files.
[sdk] / ide / src / panels / CallStackView.ec
1 #include <stdarg.h>
2
3 import "ecere"
4 import "CodeEditor"
5
6 class CallStackView : Window
7 {
8    visible = false;
9    borderStyle = sizableDeep;
10    background = { 224, 224, 224 };
11    hasClose = true;
12    mergeMenus = false;
13    text = $"Call Stack";
14    menu = Menu { };
15    anchor = Anchor { left = 0, right = 0.2, top = 0 };
16    size.h = 200;
17
18    virtual void OnSelectFrame(int frameIndex);
19    virtual void OnToggleBreakpoint();
20
21    bool moved, logging;
22    FindDialog findDialog { master = this, editBox = editBox, isModal = true, autoCreate = false, text = $"Find" };
23
24    EditBox editBox
25    {
26       parent = this, freeCaret = true, autoEmpty = true, multiLine = true, readOnly = true;
27       hasVertScroll = true, hasHorzScroll = true, borderStyle = none;
28       anchor = Anchor { left = 20, top = 0, right = 0, bottom = 0 };
29       background = viewsBackground;
30       foreground = viewsText;
31       selectionColor = selectionColor, selectionText = selectionText;
32
33       bool NotifyDoubleClick(EditBox editBox, EditLine line, Modifiers mods)
34       {
35          int frameIndex = -1;
36          if(strcmp(editBox.line.text, "..."))
37             frameIndex = atoi(editBox.line.text);
38          OnSelectFrame(frameIndex);
39          return false;
40       }
41
42       bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
43       {
44          if(key == enter || key == keyPadEnter)
45          {
46             int frameIndex = -1;
47             if(strcmp(editBox.line.text, "..."))
48                frameIndex = atoi(editBox.line.text);
49             OnSelectFrame(frameIndex);
50             return false;
51          }
52          if(key == f9)
53          {
54             OnToggleBreakpoint();
55             return false;
56          }
57          return true;
58       }
59
60       void OnVScroll(ScrollBarAction action, int position, Key key)
61       {
62          if(anchor.left.distance)
63          {
64             Box box { 0, 0, anchor.left.distance-1, parent.clientSize.h - 1 };
65             parent.Update(box);
66          }
67          EditBox::OnVScroll(action, position, key);
68       }
69    };
70
71    Menu editMenu { menu, $"Edit", e };
72    MenuItem item;
73
74    MenuItem copyItem
75    {
76       editMenu, $"Copy", c, ctrlC;
77       bool NotifySelect(MenuItem selection, Modifiers mods)
78       {
79          editBox.Copy();
80          return true;
81       }
82    };
83    MenuDivider { editMenu };
84    MenuItem { editMenu, $"Find Previous", e, Key { f3, shift = true }, NotifySelect = MenuEditFind, id = 0 };
85    MenuItem { editMenu, $"Find Next", n, f3, NotifySelect = MenuEditFind, id = 1 };
86    MenuItem { editMenu, $"Find", f, ctrlF, NotifySelect = MenuEditFind, id = 2 };
87
88    bool MenuEditFind(MenuItem selection, Modifiers mods)
89    {
90       int64 id = selection.id;
91       char * searchString = findDialog.searchString;
92       if(id != 2 && searchString[0])
93       {
94          editBox.Find(searchString, findDialog.wholeWord, findDialog.matchCase, (bool)id);
95          return true;
96       }
97       findDialog.Create();
98       return true;
99    }
100
101    void Logf(char * format, ...)
102    {
103       char string[MAX_F_STRING*10];
104       va_list args;
105       va_start(args, format);
106       vsnprintf(string, sizeof(string), format, args);
107       string[sizeof(string)-1] = 0;
108       va_end(args);
109
110       Log(string);
111    }
112    void LogSprintf(char * entry)
113    {
114       char string[MAX_F_STRING];
115       sprintf(string, entry);
116       Log(string);
117    }
118    void LogRaw(char * entry)
119    {
120       Log(entry);
121    }
122    void Log(char * string)
123    {
124       EditLine line1;
125       EditLine line2;
126       int x1, y1, x2, y2;
127       Point scroll;
128       logging = true;
129       if(moved)
130       {
131          editBox.GetSelPos(&line1, &y1, &x1, &line2, &y2, &x2, false);
132          scroll = editBox.scroll;
133       }
134       editBox.End();
135       editBox.PutS(string);
136       editBox.Update(null);
137       if(moved)
138       {
139          editBox.scroll = scroll;
140          editBox.SetSelPos(line1, y1, x1, line2, y2, x2);
141       }
142       logging = false;
143    }
144    void Clear()
145    {
146       editBox.Clear();
147       moved = false;
148    }
149    void Home()
150    {
151       editBox.Home();
152    }
153    void Show()
154    {
155       visible = true;
156       ide.RepositionWindows(false);
157       Activate();
158    }
159 }