mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 18:19:16 +02:00
* Another libc dependency less
git-svn-id: trunk@2348 -
This commit is contained in:
parent
2a1d81db28
commit
45d159eaad
@ -79,11 +79,12 @@ end;
|
|||||||
Procedure AssignVideoBuf (OldCols, OldRows : Word);
|
Procedure AssignVideoBuf (OldCols, OldRows : Word);
|
||||||
|
|
||||||
Var NewVideoBuf,NewOldVideoBuf : PVideoBuf;
|
Var NewVideoBuf,NewOldVideoBuf : PVideoBuf;
|
||||||
S,I,C,R,NewVideoBufSize : longint;
|
I,C,R,NewVideoBufSize : longint;
|
||||||
|
s:word;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
S:=SizeOf(TVideoCell);
|
S:=sizeOf(TVideoCell);
|
||||||
NewVideoBufSize:=ScreenWidth*ScreenHeight*S;
|
NewVideoBufSize:=ScreenWidth*ScreenHeight*s;
|
||||||
GetMem(NewVideoBuf,NewVideoBufSize);
|
GetMem(NewVideoBuf,NewVideoBufSize);
|
||||||
GetMem(NewOldVideoBuf,NewVideoBufSize);
|
GetMem(NewOldVideoBuf,NewVideoBufSize);
|
||||||
// Move contents of old videobuffers to new if there are any.
|
// Move contents of old videobuffers to new if there are any.
|
||||||
|
@ -22,7 +22,7 @@ interface
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
BaseUnix, Strings, TermInfo, termio;
|
BaseUnix, Strings, termio;
|
||||||
|
|
||||||
{$i video.inc}
|
{$i video.inc}
|
||||||
|
|
||||||
@ -32,10 +32,127 @@ Type TConsoleType = (ttyNetwork
|
|||||||
,ttyFreeBSD
|
,ttyFreeBSD
|
||||||
,ttyNetBSD);
|
,ttyNetBSD);
|
||||||
|
|
||||||
|
type Ttermcode=(
|
||||||
|
enter_alt_charset_mode,
|
||||||
|
exit_alt_charset_mode,
|
||||||
|
clear_screen,
|
||||||
|
cursor_home,
|
||||||
|
cursor_normal,
|
||||||
|
cursor_visible,
|
||||||
|
cursor_invisible,
|
||||||
|
enter_ca_mode,
|
||||||
|
exit_ca_mode,
|
||||||
|
exit_am_mode,
|
||||||
|
ena_acs
|
||||||
|
);
|
||||||
|
Ttermcodes=array[Ttermcode] of Pchar;
|
||||||
|
Ptermcodes=^Ttermcodes;
|
||||||
|
|
||||||
|
const term_codes_ansi:Ttermcodes= {Linux escape sequences are equal to ansi sequences}
|
||||||
|
(#$1B#$5B#$31#$31#$6D, {enter_alt_charset_mode}
|
||||||
|
#$1B#$5B#$31#$30#$6D, {exit_alt_charset_mode}
|
||||||
|
#$1B#$5B#$48#$1B#$5B#$4A, {clear_screen}
|
||||||
|
#$1B#$5B#$48, {cursor_home}
|
||||||
|
nil, {cursor_normal}
|
||||||
|
nil, {cursor_visible}
|
||||||
|
nil, {cursor_invisible}
|
||||||
|
nil, {enter_ca_mode}
|
||||||
|
nil, {exit_ca_mode}
|
||||||
|
nil, {exit_am_mode}
|
||||||
|
nil); {ena_acs}
|
||||||
|
|
||||||
|
term_codes_freebsd:Ttermcodes=
|
||||||
|
(nil, {enter_alt_charset_mode}
|
||||||
|
nil, {exit_alt_charset_mode}
|
||||||
|
#$1B#$5B#$48#$1B#$5B#$4A, {clear_screen}
|
||||||
|
#$1B#$5B#$48, {cursor_home}
|
||||||
|
#$1B#$5B#$3D#$30#$43, {cursor_normal}
|
||||||
|
#$1B#$5B#$3D#$31#$43, {cursor_visible}
|
||||||
|
nil, {cursor_invisible}
|
||||||
|
nil, {enter_ca_mode}
|
||||||
|
nil, {exit_ca_mode}
|
||||||
|
nil, {exit_am_mode}
|
||||||
|
nil); {ena_acs}
|
||||||
|
|
||||||
|
term_codes_linux:Ttermcodes=
|
||||||
|
(#$1B#$5B#$31#$31#$6D, {enter_alt_charset_mode}
|
||||||
|
#$1B#$5B#$31#$30#$6D, {exit_alt_charset_mode}
|
||||||
|
#$1B#$5B#$48#$1B#$5B#$4A, {clear_screen}
|
||||||
|
#$1B#$5B#$48, {cursor_home}
|
||||||
|
#$1B#$5B#$3F#$32#$35#$68#$1B#$5B#$3F#$30#$63, {cursor_normal}
|
||||||
|
#$1B#$5B#$3F#$32#$35#$68#$1B#$5B#$3F#$30#$63, {cursor_visible}
|
||||||
|
#$1B#$5B#$3F#$32#$35#$6C, {cursor_invisible}
|
||||||
|
nil, {enter_ca_mode}
|
||||||
|
nil, {exit_ca_mode}
|
||||||
|
nil, {exit_am_mode}
|
||||||
|
nil); {ena_acs}
|
||||||
|
|
||||||
|
term_codes_vt100:Ttermcodes=
|
||||||
|
(#$0E, {enter_alt_charset_mode}
|
||||||
|
#$0F, {exit_alt_charset_mode}
|
||||||
|
#$1B#$5B#$48#$1B#$5B#$4A#$24#$3C#$35#$30#$3E, {clear_screen}
|
||||||
|
#$1B#$5B#$48, {cursor_home}
|
||||||
|
nil, {cursor_normal}
|
||||||
|
nil, {cursor_visible}
|
||||||
|
nil, {cursor_invisible}
|
||||||
|
nil, {enter_ca_mode}
|
||||||
|
nil, {exit_ca_mode}
|
||||||
|
#$1B#$5B#$3F#$37#$6C, {exit_am_mode}
|
||||||
|
#$1B#$28#$42#$1B#$29#$30); {ena_acs}
|
||||||
|
|
||||||
|
term_codes_vt220:Ttermcodes=
|
||||||
|
(#$1B#$28#$30#$24#$3C#$32#$3E, {enter_alt_charset_mode}
|
||||||
|
#$1B#$28#$42#$24#$3C#$34#$3E, {exit_alt_charset_mode}
|
||||||
|
#$1B#$5B#$48#$1B#$5B#$4A, {clear_screen}
|
||||||
|
#$1B#$5B#$48, {cursor_home}
|
||||||
|
nil, {cursor_normal}
|
||||||
|
nil, {cursor_visible}
|
||||||
|
nil, {cursor_invisible}
|
||||||
|
nil, {enter_ca_mode}
|
||||||
|
nil, {exit_ca_mode}
|
||||||
|
#$1B#$5B#$3F#$37#$6C, {exit_am_mode}
|
||||||
|
#$1B#$29#$30); {ena_acs}
|
||||||
|
|
||||||
|
term_codes_xterm:Ttermcodes=
|
||||||
|
(#$0E, {enter_alt_charset_mode}
|
||||||
|
#$0F, {exit_alt_charset_mode}
|
||||||
|
#$1B#$5B#$48#$1B#$5B#$32#$4A, {clear_screen}
|
||||||
|
#$1B#$5B#$48, {cursor_home}
|
||||||
|
#$1B#$5B#$3F#$31#$32#$6C#$1B#$5B#$3F#$32#$35#$68, {cursor_normal}
|
||||||
|
#$1B#$5B#$3F#$31#$32#$3B#$32#$35#$68, {cursor_visible}
|
||||||
|
#$1B#$5B#$3F#$32#$35#$6C, {cursor_invisible}
|
||||||
|
#$1B#$5B#$3F#$31#$30#$34#$39#$68, {enter_ca_mode}
|
||||||
|
#$1B#$5B#$3F#$31#$30#$34#$39#$6C, {exit_ca_mode}
|
||||||
|
#$1B#$5B#$3F#$37#$6C, {exit_am_mode}
|
||||||
|
#$1B#$28#$42#$1B#$29#$30); {ena_acs}
|
||||||
|
|
||||||
|
|
||||||
|
const terminal_names:array[0..8] of string[7]=(
|
||||||
|
'ansi',
|
||||||
|
'cons',
|
||||||
|
'eterm',
|
||||||
|
'gnome',
|
||||||
|
'konsole',
|
||||||
|
'linux',
|
||||||
|
'vt100',
|
||||||
|
'vt220',
|
||||||
|
'xterm');
|
||||||
|
terminal_data:array[0..8] of Ptermcodes=(
|
||||||
|
@term_codes_ansi,
|
||||||
|
@term_codes_freebsd,
|
||||||
|
@term_codes_xterm,
|
||||||
|
@term_codes_xterm,
|
||||||
|
@term_codes_xterm,
|
||||||
|
@term_codes_linux,
|
||||||
|
@term_codes_vt100,
|
||||||
|
@term_codes_vt220,
|
||||||
|
@term_codes_xterm);
|
||||||
|
|
||||||
var
|
var
|
||||||
LastCursorType : byte;
|
LastCursorType : byte;
|
||||||
TtyFd: Longint;
|
TtyFd: Longint;
|
||||||
Console: TConsoleType;
|
Console: TConsoleType;
|
||||||
|
cur_term_strings:Ptermcodes;
|
||||||
{$ifdef logging}
|
{$ifdef logging}
|
||||||
f: file;
|
f: file;
|
||||||
|
|
||||||
@ -51,7 +168,7 @@ const
|
|||||||
|
|
||||||
const
|
const
|
||||||
|
|
||||||
can_delete_term : boolean = false;
|
{ can_delete_term : boolean = false;}
|
||||||
ACSIn : string = '';
|
ACSIn : string = '';
|
||||||
ACSOut : string = '';
|
ACSOut : string = '';
|
||||||
InACS : boolean =false;
|
InACS : boolean =false;
|
||||||
@ -147,7 +264,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function SendEscapeSeqNdx(Ndx: Word) : boolean;
|
function SendEscapeSeqNdx(Ndx:Ttermcode) : boolean;
|
||||||
var
|
var
|
||||||
P,pdelay: PChar;
|
P,pdelay: PChar;
|
||||||
begin
|
begin
|
||||||
@ -403,7 +520,7 @@ end;
|
|||||||
Spaces:=0;
|
Spaces:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetTermString(ndx:word):String;
|
function GetTermString(ndx:Ttermcode):String;
|
||||||
var
|
var
|
||||||
P,pdelay: PChar;
|
P,pdelay: PChar;
|
||||||
begin
|
begin
|
||||||
@ -681,8 +798,11 @@ var
|
|||||||
WS: packed record
|
WS: packed record
|
||||||
ws_row, ws_col, ws_xpixel, ws_ypixel: Word;
|
ws_row, ws_col, ws_xpixel, ws_ypixel: Word;
|
||||||
end;
|
end;
|
||||||
Err: Longint;
|
{ Err: Longint;}
|
||||||
prev_term : TerminalCommon_ptr1;
|
{ prev_term : TerminalCommon_ptr1;}
|
||||||
|
term:string;
|
||||||
|
i:word;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifndef CPUI386}
|
{$ifndef CPUI386}
|
||||||
LowAscii:=false;
|
LowAscii:=false;
|
||||||
@ -697,7 +817,8 @@ begin
|
|||||||
fpWrite(stdoutputhandle,fontstr[1],length(fontstr));
|
fpWrite(stdoutputhandle,fontstr[1],length(fontstr));
|
||||||
{ running on a tty, find out whether locally or remotely }
|
{ running on a tty, find out whether locally or remotely }
|
||||||
TTyfd:=-1;
|
TTyfd:=-1;
|
||||||
Console:=TTyNetwork; {Default: Network or other vtxxx tty}
|
Console:=TTyNetwork; {Default: Network or other vtxxx tty}
|
||||||
|
cur_term_strings:=@term_codes_vt100; {Default: vt100}
|
||||||
if (Copy(ThisTTY, 1, 8) = '/dev/tty') and
|
if (Copy(ThisTTY, 1, 8) = '/dev/tty') and
|
||||||
not (ThisTTY[9] IN ['p'..'u','P']) then // FreeBSD has these
|
not (ThisTTY[9] IN ['p'..'u','P']) then // FreeBSD has these
|
||||||
begin
|
begin
|
||||||
@ -724,8 +845,12 @@ begin
|
|||||||
Console:=ttyFreeBSD; {TTYFd ?}
|
Console:=ttyFreeBSD; {TTYFd ?}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
If (Copy(fpGetEnv('TERM'),1,4)='cons') Then // cons<lines>
|
term:=fpgetenv('TERM');
|
||||||
Console:=ttyFreeBSD;
|
for i:=low(terminal_names) to high(terminal_names) do
|
||||||
|
if copy(term,1,length(terminal_names[i]))=terminal_names[i] then
|
||||||
|
cur_term_strings:=terminal_data[i];
|
||||||
|
if cur_term_strings=@term_codes_freebsd then
|
||||||
|
console:=ttyFreeBSD;
|
||||||
{$ifdef linux}
|
{$ifdef linux}
|
||||||
If Console<>ttylinux Then
|
If Console<>ttylinux Then
|
||||||
begin
|
begin
|
||||||
@ -756,9 +881,9 @@ begin
|
|||||||
if Console<>ttylinux then
|
if Console<>ttylinux then
|
||||||
begin
|
begin
|
||||||
{$endif}
|
{$endif}
|
||||||
prev_term:=cur_term;
|
{ prev_term:=cur_term;
|
||||||
setupterm(nil, stdoutputhandle, err);
|
setupterm(nil, stdoutputhandle, err);
|
||||||
can_delete_term:=assigned(prev_term) and (prev_term<>cur_term);
|
can_delete_term:=assigned(prev_term) and (prev_term<>cur_term);}
|
||||||
SendEscapeSeqNdx(cursor_home);
|
SendEscapeSeqNdx(cursor_home);
|
||||||
SendEscapeSeqNdx(cursor_normal);
|
SendEscapeSeqNdx(cursor_normal);
|
||||||
SendEscapeSeqNdx(cursor_visible);
|
SendEscapeSeqNdx(cursor_visible);
|
||||||
@ -768,16 +893,16 @@ begin
|
|||||||
SendEscapeSeqNdx(exit_am_mode);
|
SendEscapeSeqNdx(exit_am_mode);
|
||||||
{$ifdef linux}
|
{$ifdef linux}
|
||||||
end
|
end
|
||||||
else if not assigned(cur_term) then
|
{ else if not assigned(cur_term) then
|
||||||
begin
|
begin
|
||||||
setupterm(nil, stdoutputhandle, err);
|
setupterm(nil, stdoutputhandle, err);
|
||||||
can_delete_term:=false;
|
can_delete_term:=false;
|
||||||
end;
|
end};
|
||||||
{$endif}
|
{$endif}
|
||||||
if assigned(cur_term_Strings) then
|
if assigned(cur_term_Strings) then
|
||||||
begin
|
begin
|
||||||
ACSIn:=StrPas(cur_term_Strings^[enter_alt_charset_mode]);
|
ACSIn:=StrPas(cur_term_strings^[enter_alt_charset_mode]);
|
||||||
ACSOut:=StrPas(cur_term_Strings^[exit_alt_charset_mode]);
|
ACSOut:=StrPas(cur_term_strings^[exit_alt_charset_mode]);
|
||||||
if (ACSIn<>'') and (ACSOut<>'') then
|
if (ACSIn<>'') and (ACSOut<>'') then
|
||||||
SendEscapeSeqNdx(ena_acs);
|
SendEscapeSeqNdx(ena_acs);
|
||||||
if pos('$<',ACSIn)>0 then
|
if pos('$<',ACSIn)>0 then
|
||||||
@ -828,11 +953,11 @@ begin
|
|||||||
According to Pierre this could be more a NCurses version thing that
|
According to Pierre this could be more a NCurses version thing that
|
||||||
a FreeBSD one. FreeBSD 4.4 has ncurses 5.
|
a FreeBSD one. FreeBSD 4.4 has ncurses 5.
|
||||||
MvdV102003: Since I ran 1.1 with newer FreeBSD without problem, I let it be for now}
|
MvdV102003: Since I ran 1.1 with newer FreeBSD without problem, I let it be for now}
|
||||||
if can_delete_term then
|
{ if can_delete_term then
|
||||||
begin
|
begin
|
||||||
del_curterm(cur_term);
|
del_curterm(cur_term);
|
||||||
can_delete_term:=false;
|
can_delete_term:=false;
|
||||||
end;
|
end;}
|
||||||
{$ifdef logging}
|
{$ifdef logging}
|
||||||
close(f);
|
close(f);
|
||||||
{$endif logging}
|
{$endif logging}
|
||||||
|
Loading…
Reference in New Issue
Block a user