Screen width more than 255 chars (for Unixes at least)

This commit is contained in:
Margers 2025-01-09 21:21:09 +00:00 committed by Michael Van Canneyt
parent 30dcf0b61a
commit 4e96751cb7
9 changed files with 46 additions and 26 deletions

View File

@ -744,7 +744,7 @@ BEGIN
State := sfVisible + sfSelected + sfFocused + State := sfVisible + sfSelected + sfFocused +
sfModal + sfExposed; { Deafult states } sfModal + sfExposed; { Deafult states }
Options := 0; { No options set } Options := 0; { No options set }
Size.X := ScreenWidth; { Set x size value } Size.X := Min(ScreenWidth,MaxViewWidth); { Set x size value }
Size.Y := ScreenHeight; { Set y size value } Size.Y := ScreenHeight; { Set y size value }
InitStatusLine; { Create status line } InitStatusLine; { Create status line }
InitMenuBar; { Create a bar menu } InitMenuBar; { Create a bar menu }

View File

@ -719,8 +719,8 @@ CONST
VAR VAR
MouseIntFlag: Byte; { Mouse in int flag } MouseIntFlag: Byte; { Mouse in int flag }
MouseButtons: Byte; { Mouse button state } MouseButtons: Byte; { Mouse button state }
ScreenWidth : Byte; { Screen text width } ScreenWidth : Sw_Word; { Screen text width }
ScreenHeight: Byte; { Screen text height } ScreenHeight: Sw_Word; { Screen text height }
ScreenMode : TVideoMode; { Screen mode } ScreenMode : TVideoMode; { Screen mode }
MouseWhere : TPoint; { Mouse position } MouseWhere : TPoint; { Mouse position }
@ -753,11 +753,6 @@ CONST EventQSize = 16; { Default int bufsize }
{---------------------------------------------------------------------------} {---------------------------------------------------------------------------}
CONST QueueMax = 64; { Max new queue size } CONST QueueMax = 64; { Max new queue size }
{---------------------------------------------------------------------------}
{ MAX WIEW WIDTH to avoid TDrawBuffer overrun in views unit }
{---------------------------------------------------------------------------}
CONST MaxViewWidth = 255; { Max view width }
{***************************************************************************} {***************************************************************************}
{ PRIVATE INTERNAL TYPES } { PRIVATE INTERNAL TYPES }
{***************************************************************************} {***************************************************************************}
@ -1611,9 +1606,6 @@ begin
{$IFDEF FPC_DOTTEDUNITS}System.Console.{$ENDIF}Video.SetVideoMode(StoreScreenMode); {$IFDEF FPC_DOTTEDUNITS}System.Console.{$ENDIF}Video.SetVideoMode(StoreScreenMode);
GetVideoMode(ScreenMode); GetVideoMode(ScreenMode);
end; end;
if ScreenWidth > MaxViewWidth then
ScreenWidth := MaxViewWidth;
ScreenWidth:={$IFDEF FPC_DOTTEDUNITS}System.Console.{$ENDIF}Video.ScreenWidth; ScreenWidth:={$IFDEF FPC_DOTTEDUNITS}System.Console.{$ENDIF}Video.ScreenWidth;
ScreenHeight:={$IFDEF FPC_DOTTEDUNITS}System.Console.{$ENDIF}Video.ScreenHeight; ScreenHeight:={$IFDEF FPC_DOTTEDUNITS}System.Console.{$ENDIF}Video.ScreenHeight;
VideoInitialized:=true; VideoInitialized:=true;

View File

@ -349,7 +349,8 @@ var c_normal,c_normal_x,c_select,c_focus:byte;
function draw_item(cur:pointer;level,position:sw_integer; function draw_item(cur:pointer;level,position:sw_integer;
lines:longint;flags:word):boolean; lines:longint;flags:word):boolean;
var c,i:byte; var c:byte;
i:sw_integer;
{$ifdef FV_UNICODE} {$ifdef FV_UNICODE}
s,t:UnicodeString; s,t:UnicodeString;
{$else FV_UNICODE} {$else FV_UNICODE}

View File

@ -281,8 +281,15 @@ CONST
{---------------------------------------------------------------------------} {---------------------------------------------------------------------------}
CONST CONST
wnNoNumber = 0; { Window has no num } wnNoNumber = 0; { Window has no num }
MaxViewWidth = 255; { Max view width } {$ifdef unix}
MaxViewWidth = 1024; { Max view width }
{$else}
{$ifdef windows}
MaxViewWidth = 255; { Max view width }
{$else}
MaxViewWidth = 255; { Max view width }
{$endif}
{$endif}
{***************************************************************************} {***************************************************************************}
{ PUBLIC TYPE DEFINITIONS } { PUBLIC TYPE DEFINITIONS }
@ -1829,6 +1836,8 @@ begin
Origin := Bounds.A; { Get first corner } Origin := Bounds.A; { Get first corner }
Size := Bounds.B; { Get second corner } Size := Bounds.B; { Get second corner }
Dec(Size.X,Origin.X); Dec(Size.X,Origin.X);
{ in case MaxViewWidth is smaller than ScreenWidth }
Size.X:=Min(Size.X,MaxViewWidth); { adjust to be in bounds of TDrawBuffer }
Dec(Size.Y,Origin.Y); Dec(Size.Y,Origin.Y);
end; end;
@ -4397,7 +4406,9 @@ begin
G:=p^.Owner; G:=p^.Owner;
if (G^.buffer<>Nil) then if (G^.buffer<>Nil) then
begin begin
BufPos:=G^.size.x * staticVar2.y + x1; { find view position on global screen, }
{ use ScreenWidth for that }
BufPos:={G^.size.x} ScreenWidth * staticVar2.y + x1;
SrcPos:=x1 - staticVar2.offset; SrcPos:=x1 - staticVar2.offset;
l:=x2-x1; l:=x2-x1;
if (shadowCounter=0) then if (shadowCounter=0) then

View File

@ -74,9 +74,11 @@ uses Objects,Views,App,MsgBox,
const const
MaxStatusLevel = 10; MaxStatusLevel = 10;
{$if MaxViewWidth < 256}
var StatusStack : array[0..MaxStatusLevel] of string[MaxViewWidth]; var StatusStack : array[0..MaxStatusLevel] of string[MaxViewWidth];
{$else}
var StatusStack : array[0..MaxStatusLevel] of string[255{MaxViewWidth}];
{$endif}
const const
StatusStackPtr : integer = 0; StatusStackPtr : integer = 0;

View File

@ -1497,7 +1497,7 @@ end;
procedure TIDEApp.ShowIDEScreen; procedure TIDEApp.ShowIDEScreen;
var oldH,oldW : byte; var oldH,oldW : Sw_Word;
begin begin
if Assigned(UserScreen) then if Assigned(UserScreen) then
UserScreen^.SaveConsoleScreen; UserScreen^.SaveConsoleScreen;

View File

@ -154,7 +154,11 @@ type
{$endif WITH_CRT} {$endif WITH_CRT}
const const
{$if defined(unix) or defined(windows)}
MaxVideoLine = 65520 div ({2*}255); { maximum number of lines (don't have to fit in 64K) }
{$else}
MaxVideoLine = 65520 div (2*MaxViewWidth); { maximum number of lines that fit in 64K } MaxVideoLine = 65520 div (2*MaxViewWidth); { maximum number of lines that fit in 64K }
{$endif}
type type
TAnsiBuffer = array[0..MaxViewWidth*MaxVideoLine] of word; TAnsiBuffer = array[0..MaxViewWidth*MaxVideoLine] of word;
@ -687,7 +691,7 @@ begin
end; end;
procedure TANSIViewConsole.ClrScr; procedure TANSIViewConsole.ClrScr;
var X,Y: word; var X,Y: sw_word;
Pos: longint; Pos: longint;
begin begin
GotoXY(1,1); GotoXY(1,1);
@ -700,7 +704,7 @@ begin
end; end;
procedure TANSIViewConsole.ClrEol; procedure TANSIViewConsole.ClrEol;
var X,Y: word; var X,Y: sw_word;
Pos: longint; Pos: longint;
begin begin
if Owner<>nil then if Owner<>nil then
@ -765,7 +769,7 @@ begin
end; end;
procedure TANSIViewConsole.GotoXY(X,Y: integer); procedure TANSIViewConsole.GotoXY(X,Y: integer);
var W: word; var W: sw_word;
begin begin
if Owner<>nil then if Owner<>nil then
while Y>MaxVideoLine do while Y>MaxVideoLine do
@ -904,7 +908,7 @@ begin
end; end;
procedure TANSIBackgroundConsole.ClrScr; procedure TANSIBackgroundConsole.ClrScr;
var X,Y: word; var X,Y: sw_word;
Pos: longint; Pos: longint;
begin begin
GotoXY(1,1); GotoXY(1,1);
@ -918,7 +922,7 @@ begin
end; end;
procedure TANSIBackgroundConsole.ClrEol; procedure TANSIBackgroundConsole.ClrEol;
var X,Y: word; var X,Y: sw_word;
Pos: longint; Pos: longint;
begin begin
if Owner<>nil then if Owner<>nil then
@ -975,7 +979,7 @@ begin
end; end;
procedure TANSIBackgroundConsole.GotoXY(X,Y: integer); procedure TANSIBackgroundConsole.GotoXY(X,Y: integer);
var W: word; var W: sw_word;
begin begin
if Owner<>nil then if Owner<>nil then
while Y>MaxVideoLine do while Y>MaxVideoLine do

View File

@ -4064,7 +4064,11 @@ var SelectColor,
Color: word; Color: word;
ColorTab: array[coFirstColor..coLastColor] of word; ColorTab: array[coFirstColor..coLastColor] of word;
ErrorLine: integer; ErrorLine: integer;
{$if MaxViewWidth < 256}
ErrorMsg: string[MaxViewWidth]; ErrorMsg: string[MaxViewWidth];
{$else}
ErrorMsg: string[255];
{$endif}
function CombineColors(Orig,Modifier: byte): byte; function CombineColors(Orig,Modifier: byte): byte;
var Color: byte; var Color: byte;
begin begin
@ -4232,7 +4236,7 @@ begin
FreeFormat[X]:=false; FreeFormat[X]:=false;
end; end;
{ redundant check, for loop condition is taking care of correct range { redundant check, for loop condition is taking care of coorect range
if (0<=LSX+X-1-Delta.X) and (LSX+X-1-Delta.X<MaxViewWidth) then } if (0<=LSX+X-1-Delta.X) and (LSX+X-1-Delta.X<MaxViewWidth) then }
MoveChar(B[LSX+X-1-Delta.X],C,Color,1); MoveChar(B[LSX+X-1-Delta.X],C,Color,1);
end; { for X:=1 to ... } end; { for X:=1 to ... }

View File

@ -646,11 +646,17 @@ var
end; end;
procedure OutSpaces; procedure OutSpaces;
var SpaceLen : longint;
begin begin
if (Spaces=0) then if (Spaces=0) then
exit; exit;
OutClr(SpaceFg,SpaceBg,SpaceAttr); OutClr(SpaceFg,SpaceBg,SpaceAttr);
OutData(Space(Spaces)); repeat
SpaceLen:=Spaces;
if SpaceLen > 200 then SpaceLen:=200; {have to fit in ShortString}
OutData(Space(SpaceLen));
Spaces:=Spaces-SpaceLen;
until Spaces = 0;
LastX:=x; LastX:=x;
LastY:=y; LastY:=y;
Spaces:=0; Spaces:=0;