* Make hack uglier, so it works better.

git-svn-id: trunk@3374 -
This commit is contained in:
daniel 2006-04-29 21:43:37 +00:00
parent 91434bd791
commit 469789071d

View File

@ -196,6 +196,7 @@ const
const const
oldmeta : longint = 0; oldmeta : longint = 0;
meta : longint = 0; meta : longint = 0;
double_esc_hack_enabled : boolean = false;
var oldesc0,oldesc1,oldesc2,oldesc4,oldesc8:word; var oldesc0,oldesc1,oldesc2,oldesc4,oldesc8:word;
@ -690,7 +691,7 @@ begin
{This is a distusting hack for certain even more disgusting xterms: Some of {This is a distusting hack for certain even more disgusting xterms: Some of
them send two escapes for an alt-key. If we wouldn't do this, we would need them send two escapes for an alt-key. If we wouldn't do this, we would need
to put a lot of entries twice in the table.} to put a lot of entries twice in the table.}
if (st[1]=#27) and (st[2]='#27') and if double_esc_hack_enabled and (st[1]=#27) and (st[2]='#27') and
(st[3] in ['a'..'z','A'..'Z','0'..'9','-','+','_','=']) then (st[3] in ['a'..'z','A'..'Z','0'..'9','-','+','_','=']) then
inc(p); inc(p);
NPT:=RootTree[St[p]]; NPT:=RootTree[St[p]];
@ -1126,15 +1127,25 @@ begin
if inhead=intail then if inhead=intail then
fpSelect(StdInputHandle+1,@fdsin,nil,nil,10); fpSelect(StdInputHandle+1,@fdsin,nil,nil,10);
ch:=ttyRecvChar; ch:=ttyRecvChar;
if ch=#27 then if (ch=#27) and double_esc_hack_enabled then
begin begin
{This is the same hack as in findsequence; see findsequence for {This is the same hack as in findsequence; see findsequence for
explanation.} explanation.}
ch:=ttyrecvchar; ch:=ttyrecvchar;
if not(ch in ['a'..'z','A'..'Z','0'..'9','-','+','_','=']) then {Alt+O cannot be used in this situation, it can be a function key.}
if not(ch in ['a'..'z','A'..'N','P'..'Z','0'..'9','-','+','_','=']) then
begin begin
pushkey(ch); if intail=0 then
intail:=insize
else
dec(intail);
inbuf[intail]:=ch;
ch:=#27; ch:=#27;
end
else
begin
write(#27'[?1036l');
double_esc_hack_enabled:=false;
end; end;
end; end;
NNPT:=FindChild(ord(ch),NPT); NNPT:=FindChild(ord(ch),NPT);
@ -1273,7 +1284,10 @@ begin
if copy(fpgetenv('TERM'),1,5)='xterm' then if copy(fpgetenv('TERM'),1,5)='xterm' then
{The alt key should generate an escape prefix. Save the old setting {The alt key should generate an escape prefix. Save the old setting
make make it send that escape prefix.} make make it send that escape prefix.}
begin
write(#27'[?1036s'#27'[?1036h'); write(#27'[?1036s'#27'[?1036h');
double_esc_hack_enabled:=true;
end;
{$ifdef linux} {$ifdef linux}
end; end;
{$endif} {$endif}