Browse Source

* moved the code from the libgdb.a interface for setting maximum width and then
restoring it from InternalGetValue to new methods (MaxWidth and NormWidth), so
they can be reused by other methods as well.

git-svn-id: trunk@30298 -

nickysn 10 years ago
parent
commit
aece198492
1 changed files with 50 additions and 30 deletions
  1. 50 30
      packages/gdbint/src/gdbcon.pp

+ 50 - 30
packages/gdbint/src/gdbcon.pp

@@ -32,6 +32,10 @@ type
   PGDBController=^TGDBController;
   PGDBController=^TGDBController;
   TGDBController=object(TGDBInterface)
   TGDBController=object(TGDBInterface)
   private
   private
+    SavedWindowWidth : longint;
+    { width }
+    procedure MaxWidth;
+    procedure NormWidth;
     { print }
     { print }
     function InternalGetValue(Const expr : string) : AnsiString;
     function InternalGetValue(Const expr : string) : AnsiString;
   public
   public
@@ -441,28 +445,11 @@ begin
   SetCommand:=true;
   SetCommand:=true;
 end;
 end;
 
 
-{ print }
-
-function TrimEnd(s: AnsiString): AnsiString;
-var
-  I: LongInt;
-begin
-  if (s<>'') and (s[Length(s)]=#10) then
-  begin
-    I:=Length(s);
-    while (i>1) and ((s[i-1]=' ') or (s[i-1]=#9)) do
-      dec(i);
-	delete(s,i,Length(s)-i+1);
-  end;
-  TrimEnd:=s;
-end;
+{ width }
 
 
-function TGDBController.InternalGetValue(Const expr : string) : AnsiString;
+procedure TGDBController.MaxWidth;
 var
 var
   p,p2,p3 : pchar;
   p,p2,p3 : pchar;
-  st : string;
-  WindowWidth : longint;
-  saved_got_error: Boolean;
 begin
 begin
   Command('show width');
   Command('show width');
   p:=GetOutput;
   p:=GetOutput;
@@ -484,12 +471,49 @@ begin
   p3:=strpos(p,'.');
   p3:=strpos(p,'.');
   if assigned(p3) then
   if assigned(p3) then
     p3^:=#0;
     p3^:=#0;
-  WindowWidth:=-1;
-  val(strpas(p),WindowWidth);
-  if WindowWidth<>-1 then
+  SavedWindowWidth:=-1;
+  val(strpas(p),SavedWindowWidth);
+  if SavedWindowWidth<>-1 then
     Command('set width 0xffffffff');
     Command('set width 0xffffffff');
-  Command('p '+expr);
+end;
+
+procedure TGDBController.NormWidth;
+var
+  st : string;
+  saved_got_error : boolean;
+begin
   saved_got_error:=got_error;
   saved_got_error:=got_error;
+  if SavedWindowWidth<>-1 then
+    begin
+      str(SavedWindowWidth,st);
+      Command('set width '+St);
+    end;
+  got_error:=saved_got_error;
+end;
+
+{ print }
+
+function TrimEnd(s: AnsiString): AnsiString;
+var
+  I: LongInt;
+begin
+  if (s<>'') and (s[Length(s)]=#10) then
+  begin
+    I:=Length(s);
+    while (i>1) and ((s[i-1]=' ') or (s[i-1]=#9)) do
+      dec(i);
+	delete(s,i,Length(s)-i+1);
+  end;
+  TrimEnd:=s;
+end;
+
+function TGDBController.InternalGetValue(Const expr : string) : AnsiString;
+var
+  p,p2 : pchar;
+begin
+  MaxWidth;
+
+  Command('p '+expr);
   p:=GetOutput;
   p:=GetOutput;
   if assigned(p) then
   if assigned(p) then
     p2:=strpos(p,'=')
     p2:=strpos(p,'=')
@@ -504,16 +528,12 @@ begin
     p:=strpos(p,')')+1;
     p:=strpos(p,')')+1;
   while p^ in [' ',#9] do
   while p^ in [' ',#9] do
     inc(p);
     inc(p);
-  if assigned(p) and not saved_got_error then
+  if assigned(p) and not got_error then
     InternalGetValue:=TrimEnd(AnsiString(p))
     InternalGetValue:=TrimEnd(AnsiString(p))
   else
   else
     InternalGetValue:=TrimEnd(AnsiString(GetError));
     InternalGetValue:=TrimEnd(AnsiString(GetError));
-  if WindowWidth<>-1 then
-    begin
-      str(WindowWidth,st);
-      Command('set width '+St);
-    end;
-  got_error:=saved_got_error;
+
+  NormWidth;
 end;
 end;