From 9ca67e6c0bb20535f8309ca0366f87a52b31a2c5 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 26 Jun 2006 06:05:42 +0000 Subject: [PATCH] Merged revisions 3243-3244,3345-3346,3367,3374,3393,3434,3698,3767,3782,3812-3813,3841,3910 via svnmerge from http://peter@svn.freepascal.org/svn/fpc/trunk ........ r3243 | daniel | 2006-04-17 14:39:02 +0200 (Mon, 17 Apr 2006) | 2 lines * Unix video unit character set conversion overhaul ........ r3244 | daniel | 2006-04-17 15:01:02 +0200 (Mon, 17 Apr 2006) | 2 lines * Conversion tables for video unit. ........ r3345 | daniel | 2006-04-27 22:15:57 +0200 (Thu, 27 Apr 2006) | 2 lines * Fix exiting acs after screen update ........ r3346 | daniel | 2006-04-27 23:00:46 +0200 (Thu, 27 Apr 2006) | 2 lines * Force VGA colours, regardless of xterm background colour. ........ r3367 | daniel | 2006-04-29 20:33:51 +0200 (Sat, 29 Apr 2006) | 2 lines * Another xterm hack :( ........ r3374 | daniel | 2006-04-29 23:43:37 +0200 (Sat, 29 Apr 2006) | 2 lines * Make hack uglier, so it works better. ........ r3393 | jonas | 2006-04-30 22:51:02 +0200 (Sun, 30 Apr 2006) | 2 lines * fixed compilation on non-Linux ........ r3434 | daniel | 2006-05-06 20:39:32 +0200 (Sat, 06 May 2006) | 2 lines * Codepage code had a bug ........ r3698 | daniel | 2006-05-27 18:42:47 +0200 (Sat, 27 May 2006) | 2 lines * Set standard I/O line ending to #13#10 when keyboard in raw mode. ........ r3767 | daniel | 2006-06-02 22:46:46 +0200 (Fri, 02 Jun 2006) | 2 lines * Fix window resizing in X. ........ r3782 | hajny | 2006-06-04 01:50:53 +0200 (Sun, 04 Jun 2006) | 1 line * another cleanup of unnecessary variables ........ r3812 | daniel | 2006-06-05 23:42:36 +0200 (Mon, 05 Jun 2006) | 2 lines + Add S_IRWXU ........ r3813 | daniel | 2006-06-05 23:46:05 +0200 (Mon, 05 Jun 2006) | 2 lines * Now right. ........ r3841 | daniel | 2006-06-11 11:00:19 +0200 (Sun, 11 Jun 2006) | 2 lines + Correct behaviour when initialization fails. ........ r3910 | daniel | 2006-06-21 16:39:44 +0200 (Wed, 21 Jun 2006) | 2 lines * Fix missing ctrlZmarkseof check. ........ git-svn-id: branches/fixes_2_0@3952 - --- fv/app.pas | 2 ++ fv/unixsmsg.inc | 4 ++-- rtl/inc/text.inc | 36 +++++++++++++++++++++++++++--------- rtl/inc/video.inc | 21 ++++++++++++--------- rtl/inc/videoh.inc | 17 +++++++++++++---- rtl/linux/ostypes.inc | 1 + rtl/os2/keyboard.pp | 1 - rtl/os2/video.pp | 1 - rtl/unix/keyboard.pp | 1 + rtl/unix/video.pp | 26 +++++++++++++++++++++++--- 10 files changed, 81 insertions(+), 29 deletions(-) diff --git a/fv/app.pas b/fv/app.pas index 06d1146800..aeb90fafc7 100644 --- a/fv/app.pas +++ b/fv/app.pas @@ -892,6 +892,8 @@ begin { InitMemory;} InitScreen; Video.SetVideoMode(Mode); + ScreenWidth:=Video.ScreenWidth; + ScreenHeight:=Video.ScreenHeight; Buffer := Views.PVideoBuf(VideoBuf); R.Assign(0, 0, ScreenWidth, ScreenHeight); ChangeBounds(R); diff --git a/fv/unixsmsg.inc b/fv/unixsmsg.inc index a3841e66df..7872ebafe8 100644 --- a/fv/unixsmsg.inc +++ b/fv/unixsmsg.inc @@ -112,8 +112,8 @@ begin ((winsize.ws_row<>lastxsize) or (winsize.ws_col<>lastysize)) then begin SystemEvent.typ:=SysResize; - SystemEvent.x:=WinSize.ws_row; - SystemEvent.y:=WinSize.ws_col; + SystemEvent.x:=WinSize.ws_col; + SystemEvent.y:=WinSize.ws_row; PutSystemEvent(SystemEvent); LastXSize:=WinSize.ws_row; LastYSize:=WinSize.ws_col; diff --git a/rtl/inc/text.inc b/rtl/inc/text.inc index 02295c3149..4111d0edeb 100644 --- a/rtl/inc/text.inc +++ b/rtl/inc/text.inc @@ -893,8 +893,17 @@ End; Function ReadPCharLen(var f:Text;s:pchar;maxlen:longint):longint; var sPos,len : Longint; - p,startp,maxp : pchar; + p,q,startp,maxp : pchar; + stop_chars:array[0..3] of char; + end_of_string:boolean; Begin + {Avoid use of ctrlZmarkseof in the inner loop.} + stop_chars[0]:=#13; + stop_chars[1]:=#10; + stop_chars[2]:=#0; + if ctrlZmarkseof then + stop_chars[2]:=#26; + stop_chars[3]:=#0; ReadPCharLen:=0; { Check error and if file is open } If (InOutRes<>0) then @@ -911,6 +920,7 @@ Begin end; { Read maximal until Maxlen is reached } sPos:=0; + end_of_string:=false; repeat If TextRec(f).BufPos>=TextRec(f).BufEnd Then begin @@ -924,19 +934,27 @@ Begin else maxp:=@TextRec(f).Bufptr^[TextRec(f).BufEnd]; startp:=p; - { search linefeed } - while (p#0) and (p^<>q^) do + inc(q); + if p^=q^ then + begin + end_of_string:=true; + break; + end; + inc(p); + end; { calculate read bytes } len:=p-startp; inc(TextRec(f).BufPos,Len); Move(startp^,s[sPos],Len); inc(sPos,Len); - { was it a LF or CR? then leave } - if (spos=MaxLen) or - ((p= Colors_16; end; VioGetCurPos (CursorY, CursorX, 0); - LowAscii := true; SetCursorType (LastCursorType); { Get the address of the videobuffer.} if VioGetBuf (SysVideoBuf, PWord (@VideoBufSize)^, 0) = 0 then diff --git a/rtl/unix/keyboard.pp b/rtl/unix/keyboard.pp index f58b34ba44..6d308f4e4d 100644 --- a/rtl/unix/keyboard.pp +++ b/rtl/unix/keyboard.pp @@ -1307,6 +1307,7 @@ end; procedure SysDoneKeyboard; begin {$ifdef linux} + if is_console then unpatchkeyboard; {$endif linux} diff --git a/rtl/unix/video.pp b/rtl/unix/video.pp index 26b8b58884..54dd6a3810 100644 --- a/rtl/unix/video.pp +++ b/rtl/unix/video.pp @@ -1098,11 +1098,11 @@ begin {$endif logging} { save new terminal characteristics and possible restore rawness } videoInitDone; + + decide_codepages; end else ErrorCode:=errVioInit; { not a TTY } - - decide_codepages; end; procedure SysDoneVideo; @@ -1224,13 +1224,33 @@ begin end; end; +function SysSetVideoMode(const mode:Tvideomode):boolean; + +var winsize:Twinsize; + +begin + {Due to xterm resize this procedure might get called with the new xterm + size. Approve the video mode change if the new size equals that of + the terminal window size.} + SysSetVideoMode:=false; + fpioctl(stdinputhandle,TIOCGWINSZ,@winsize); + if (mode.row=winsize.ws_row) and + (mode.col=winsize.ws_col) then + begin + screenwidth:=mode.col; + screenheight:=mode.row; + screencolor:=true; + SysSetVideoMode:=true; + end; +end; + Const SysVideoDriver : TVideoDriver = ( InitDriver : @SysInitVideo; DoneDriver : @SysDoneVideo; UpdateScreen : @SysUpdateScreen; ClearScreen : @SysClearScreen; - SetVideoMode : Nil; + SetVideoMode : @SysSetVideoMode; GetVideoModeCount : Nil; GetVideoModeData : Nil; SetCursorPos : @SysSetCursorPos;