* 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 -
This commit is contained in:
nickysn 2015-03-23 22:33:49 +00:00
parent a16ec9b64c
commit aece198492

View File

@ -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 } { width }
function TrimEnd(s: AnsiString): AnsiString; procedure TGDBController.MaxWidth;
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 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; SavedWindowWidth:=-1;
val(strpas(p),WindowWidth); val(strpas(p),SavedWindowWidth);
if WindowWidth<>-1 then 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 NormWidth;
str(WindowWidth,st);
Command('set width '+St);
end;
got_error:=saved_got_error;
end; end;