ide/CodeEditor: Customizable color scheme support
[sdk] / ide / src / panels / BreakpointsView.ec
index c95d8f1..6ac7bc5 100644 (file)
@@ -6,7 +6,7 @@ class BreakpointsView : Window
    borderStyle = sizable;
    background = { 224, 224, 224 };
    hasClose = true;
-   text = "Breakpoints";
+   text = $"Breakpoints";
    clientSize = Size { 206, 624 };
    //anchor = Anchor { left = 0.8, top = 200, right = 0, bottom = 200 };
    //size = { 150 };
@@ -14,11 +14,17 @@ class BreakpointsView : Window
    size.h = 240;
 
    bool moved, logging;
-   
+
    ListBox listBox
    {
       parent = this, resizable = true, hasHeader = true, alwaysEdit = true, collapseControl = true, size = { 206, 624 };
       anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 }; //visible = true
+      /*
+      background = colorScheme.viewsBackground;
+      foreground = colorScheme.viewsText;
+      selectionColor = colorScheme.selectionColor;
+      selectionText = colorScheme.selectionText;
+      */
 
       bool NotifyChanged(ListBox listBox, DataRow row)
       {
@@ -37,12 +43,13 @@ class BreakpointsView : Window
                   DataRow newRow = listBox.AddRow();
                   newRow.SetData(locationField, null);
                }
-               ide.workspace.ChangeBreakpoint(row, location);
+               ide.workspace.ChangeBreakpoint(row, location); // TODO make sure passing only unix style path
             }
             else
             {
-               ide.workspace.RemoveBreakpoint((Breakpoint)row.tag);
-               listBox.DeleteRow(null);
+               ide.workspace.RemoveBreakpoint((Breakpoint)(intptr)row.tag);
+               // This is already done by Workspace::RemoveBreakpoint!
+               // listBox.DeleteRow(null);
             }
          }
          else if(listBox.currentField == ignoreField || listBox.currentField == levelField)
@@ -54,12 +61,19 @@ class BreakpointsView : Window
             {
                TrimLSpaces(string, string);
                TrimRSpaces(string, string);
-               //value = atoi(string);
+               value = atoi(string);
             }
+            else if(listBox.currentField == levelField)
+               value = -1;
             //str[0] = '\0';
             //sprintf(str, "%d", value);
             //listBox.StopEditing(true);
             //row.SetData(listBox.currentField, str);
+            if((listBox.currentField == ignoreField && value < 1) ||
+                  (listBox.currentField == levelField && value < 0))
+               row.SetData(listBox.currentField, null);
+            if(listBox.currentField == levelField && value == 0)
+               row.SetData(listBox.currentField, "0");
             if(listBox.currentField == ignoreField)
                ide.workspace.ChangeBreakpointIgnore(row, value);
             else if(listBox.currentField == levelField)
@@ -77,7 +91,7 @@ class BreakpointsView : Window
          }
          return true;
       }
-      
+
       bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
       {
          if((SmartKey)key == enter)
@@ -90,7 +104,7 @@ class BreakpointsView : Window
          if(row && (SmartKey)key == del)
          {
             listBox.StopEditing(true);
-            ide.workspace.RemoveBreakpoint((Breakpoint)row.tag);
+            ide.workspace.RemoveBreakpoint((Breakpoint)(intptr)row.tag);
          }
          return true;
       }
@@ -101,15 +115,21 @@ class BreakpointsView : Window
          return true;
       }
    };
-   
-   DataField locationField { "char *", true, width = 180, header = "Location" };
-   DataField ignoreField { "char *", true, width = 72, header = "Ignore Count" };
-   DataField levelField { "char *", true, width = 50, header = "Hit Level" };
-   DataField conditionField { "char *", true, width = 130, header = "Condition" };
-   
+
+   // TODO: set field size based on font and i18n header string
+   // TODO: save column widths to ide settings
+   DataField locationField    { "char *", true , width = 220, header = $"Location" };
+   DataField hitsField        { "int"   , false, width =  28, header = $"Hits" };
+   DataField breaksField      { "int"   , false, width =  46, header = $"Breaks" };
+   DataField ignoreField      { "char *", true , width =  80, header = $"Ignore Count" };
+   DataField levelField       { "char *", true , width =  74, header = $"Stack Depth" };
+   DataField conditionField   { "char *", true , width = 130, header = $"Condition" };
+
    BreakpointsView()
    {
       listBox.AddField(locationField);
+      listBox.AddField(hitsField);
+      listBox.AddField(breaksField);
       listBox.AddField(ignoreField);
       listBox.AddField(levelField);
       listBox.AddField(conditionField);
@@ -124,13 +144,6 @@ class BreakpointsView : Window
       return true;
    }
 
-   bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-   {
-      if(active)
-         ide.RepositionWindows(false);
-      return true;
-   }
-
    bool OnClose(bool parentClosing)
    {
       visible = false;
@@ -144,9 +157,9 @@ class BreakpointsView : Window
       bool error;
       int lineActive, lineUser;
       int lineH;
-      int scrollY = listBox.scroll.y;
-      int boxH = clientSize.h;
-      
+      //int scrollY = listBox.scroll.y;
+      //int boxH = clientSize.h;
+
       displaySystem.FontExtent(listBox.font.font, " ", 1, null, &lineH);
       //Window::OnRedraw(surface);
       ide.debugger.GetCallStackCursorLine(&error, &lineActive, &lineUser);
@@ -171,6 +184,7 @@ class BreakpointsView : Window
    void Show()
    {
       visible = true;
+      ide.RepositionWindows(false);
       Activate();
    }
 
@@ -182,9 +196,8 @@ class BreakpointsView : Window
 
    void AddBreakpoint(Breakpoint bp)
    {
-      char string[32];
       DataRow row = listBox.AddRow();
-      row.tag = (int)bp;
+      row.tag = (int64)(intptr)bp;
       bp.row = row;
       UpdateBreakpoint(row);
       ide.callStackView.Update(null);
@@ -197,18 +210,24 @@ class BreakpointsView : Window
       ide.callStackView.Update(null);
       Update(null);
    }
-   
+
    void UpdateBreakpoint(DataRow row)
    {
       if(row && row.tag)
       {
          char string[32];
          char * location;
-         Breakpoint bp = (Breakpoint)row.tag;
-         location = bp.LocationToString();
+         Breakpoint bp = (Breakpoint)(intptr)row.tag;
+         location = bp.CopyUserLocationString();
+#if defined(__WIN32__)
+         ChangeCh(location, '/', '\\');
+#endif
          row.SetData(locationField, location);
          delete location;
-         sprintf(string, "%d", bp.ignore);
+         if(bp.ignore == 0)
+            string[0] = '\0';
+         else
+            sprintf(string, "%d", bp.ignore);
          row.SetData(ignoreField, string);
          if(bp.level == -1)
             string[0] = '\0';
@@ -219,9 +238,11 @@ class BreakpointsView : Window
             row.SetData(conditionField, bp.condition.expression);
          else
             row.SetData(conditionField, null);
+         row.SetData(hitsField, bp.hits);
+         row.SetData(breaksField, bp.breaks);
       }
    }
-   
+
    void Clear()
    {
       listBox.Clear();