ide/Panels: (#965) Fixed non-sensical repositioning of Windows on activation
[sdk] / ide / src / panels / WatchesView.ec
index 2abaa16..f0c1639 100644 (file)
@@ -3,7 +3,7 @@ import "ide"
 class WatchesView : Window
 {
    visible = false;
-   text = "Watches";
+   text = $"Watches";
    borderStyle = sizable;
    background = { 224, 224, 224 };
    hasClose = true;
@@ -73,10 +73,10 @@ class WatchesView : Window
          return true;
       }
    };
-   DataField expressionField { "char *", true, width = 130, header = "Expression" };
-   DataField typeField { "Type", false, width = 180, header = "Type" };
-   //DataField addressField { "char *", true, width = 80, header = "Symbol Address" };
-   DataField valueField { class(WatchMultiLineString), true, width = 330, header = "Value" };
+   DataField expressionField { "char *", true, width = 130, header = $"Expression" };
+   DataField typeField { "Type", false, width = 180, header = $"Type" };
+   //DataField addressField { "char *", true, width = 80, header = $"Symbol Address" };
+   DataField valueField { class(WatchMultiLineString), true, width = 330, header = $"Value", freeData = false };
 
    WatchesView()
    {
@@ -94,16 +94,6 @@ class WatchesView : Window
       return true;
    }
 
-   bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-   {
-      if(active)
-      {
-         //listBox.SelectRow(listBox.firstRow);
-         ide.RepositionWindows(false);
-      }
-      return true;
-   }
-
    bool OnClose(bool parentClosing)
    {
       visible = false;
@@ -115,6 +105,7 @@ class WatchesView : Window
    void Show()
    {
       visible = true;
+      ide.RepositionWindows(false);
       Activate();
    }
 
@@ -127,7 +118,7 @@ class WatchesView : Window
    void AddWatch(Watch wh)
    {
       DataRow row = listBox.AddRowAfter(listBox.lastRow.previous);
-      row.tag = (int)wh;
+      row.tag = (int64)wh;
       wh.row = row;
       UpdateWatch(wh);
    }
@@ -155,6 +146,11 @@ class WatchesView : Window
       row.SetData(expressionField, null);
       row.SetData(typeField, null);
       row.SetData(valueField, null);
+      if(ide.workspace)
+      {
+         for(w : ide.workspace.watches)
+            w.row = null;
+      }
    }
 }
 
@@ -258,7 +254,7 @@ class WatchMultiLineString : String
          char * string = this;
          char actualString[8196];
          int c, len = 0;
-         for(c = 0; (ch = string[c]); c++)
+         for(c = 0; (ch = string[c]) && len < sizeof(actualString)-1; c++)
          {
             if(ch == '\t') { actualString[len++] = '\\'; actualString[len++] = 't'; }
             else if(ch == '\r') { actualString[len++] = '\\'; actualString[len++] = 'r'; }
@@ -266,7 +262,7 @@ class WatchMultiLineString : String
             else actualString[len++] = ch;
          }
          actualString[len] = 0;
-         class(String)._vTbl[__ecereVMethodID_class_OnDisplay](class(String), actualString, surface, x, y, width, null, alignment, displayFlags);
+         ((void (*)(void *, void *, void *, int, int, int, void *, uint, uint))(void *)class(String)._vTbl[__ecereVMethodID_class_OnDisplay])(class(String), actualString, surface, x, y, width, null, alignment, displayFlags);
       }
    }
 };