New FSE features

This commit is contained in:
mysticbbs 2012-02-21 18:38:36 -05:00
parent fa8c58d162
commit 6b18527e8b
2 changed files with 105 additions and 73 deletions

View File

@ -3830,3 +3830,6 @@
+ CTRL-X now moves down one line the same as the down arrow key in the + CTRL-X now moves down one line the same as the down arrow key in the
full screen editor. full screen editor.
+ CTRL-W now deletes the word to the left of the cursor in the full
screen editor.

View File

@ -31,13 +31,13 @@ Function AnsiEditor (Var Lines: Integer; WrapPos: Byte; MaxLines: Integer; TEdit
Const Const
WinStart : Byte = 2; WinStart : Byte = 2;
WinEnd : Byte = 22; WinEnd : Byte = 22;
WinText : Byte = 7;
InsertMode : Boolean = True; InsertMode : Boolean = True;
Var Var
Done : Boolean; Done : Boolean;
Save : Boolean; Save : Boolean;
Ch : Char; Ch : Char;
tColor : Byte;
CurX : Byte; CurX : Byte;
CurY : Integer; CurY : Integer;
CurLine : Integer; CurLine : Integer;
@ -53,7 +53,7 @@ Begin
Session.io.AnsiGotoXY (CurX, CurY); Session.io.AnsiGotoXY (CurX, CurY);
End; End;
Procedure ScreenRefreshPart; Procedure TextRefreshPart;
Var Var
A, A,
B : Integer; B : Integer;
@ -77,7 +77,7 @@ Begin
UpdatePosition; UpdatePosition;
End; End;
Procedure ScreenRefreshFull; Procedure TextRefreshFull;
Var Var
A, A,
B : Integer; B : Integer;
@ -148,46 +148,47 @@ Begin
Moved := False; Moved := False;
Repeat Repeat
If Pos(' ', OldStr) = 0 Then Begin If Pos(' ', OldStr) = 0 Then Begin
Inc (Line); Inc (Line);
InsertLine (Line); InsertLine (Line);
Session.Msgs.MsgText[Line] := Copy(OldStr, CurX, Length(OldStr)); Session.Msgs.MsgText[Line] := Copy(OldStr, CurX, Length(OldStr));
Session.Msgs.MsgText[Line-1][0] := Chr(CurX - 1); Session.Msgs.MsgText[Line-1][0] := Chr(CurX - 1);
If CurX > WrapPos Then Begin If CurX > WrapPos Then Begin
Inc (NewLine); Inc (NewLine);
Inc (NewY); Inc (NewY);
CurX := 1; CurX := 1;
End;
If NewY <= WinEnd Then ScreenRefreshPart;
CurY := NewY;
CurLine := NewLine;
If CurY > WinEnd Then ScreenRefreshFull Else UpdatePosition;
Exit;
End Else Begin
A := strWrap (OldStr, NewStr, WrapPos);
If (A > 0) And (Not Moved) And (CurX > Length(OldStr) + 1) Then Begin
CurX := CurX - A;
Moved := True;
Inc (NewLine);
Inc (NewY);
End;
Session.Msgs.MsgText[Line] := OldStr;
Inc (Line);
If (Session.Msgs.MsgText[Line] = '') or ((Pos(' ', Session.Msgs.MsgText[Line]) = 0) And (Length(Session.Msgs.MsgText[Line]) >= WrapPos)) Then Begin
InsertLine(Line);
OldStr := NewStr;
End Else
OldStr := NewStr + ' ' + Session.Msgs.MsgText[Line];
End; End;
If NewY <= WinEnd Then TextRefreshPart;
CurY := NewY;
CurLine := NewLine;
If CurY > WinEnd Then TextRefreshFull Else UpdatePosition;
Exit;
End Else Begin
A := strWrap (OldStr, NewStr, WrapPos);
If (A > 0) And (Not Moved) And (CurX > Length(OldStr) + 1) Then Begin
CurX := CurX - A;
Moved := True;
Inc (NewLine);
Inc (NewY);
End;
Session.Msgs.MsgText[Line] := OldStr;
Inc (Line);
If (Session.Msgs.MsgText[Line] = '') or ((Pos(' ', Session.Msgs.MsgText[Line]) = 0) And (Length(Session.Msgs.MsgText[Line]) >= WrapPos)) Then Begin
InsertLine(Line);
OldStr := NewStr;
End Else
OldStr := NewStr + ' ' + Session.Msgs.MsgText[Line];
End;
Until Length(OldStr) <= WrapPos; Until Length(OldStr) <= WrapPos;
Session.Msgs.MsgText[Line] := OldStr; Session.Msgs.MsgText[Line] := OldStr;
@ -214,7 +215,7 @@ Begin
CurY := NewY; CurY := NewY;
CurLine := NewLine; CurLine := NewLine;
If CurY > WinEnd Then ScreenRefreshFull Else UpdatePosition; If CurY > WinEnd Then TextRefreshFull Else UpdatePosition;
End; End;
Procedure keyEnter; Procedure keyEnter;
@ -228,7 +229,7 @@ Begin
Delete (Session.Msgs.MsgText[CurLine], CurX, Length(Session.Msgs.MsgText[CurLine])); Delete (Session.Msgs.MsgText[CurLine], CurX, Length(Session.Msgs.MsgText[CurLine]));
End; End;
If CurY + 1 > WinEnd Then ScreenRefreshFull Else ScreenRefreshPart; If CurY + 1 > WinEnd Then TextRefreshFull Else TextRefreshPart;
CurX := 1; CurX := 1;
@ -243,7 +244,7 @@ Begin
If CurLine = TotalLine Then Exit; If CurLine = TotalLine Then Exit;
If CurY = WinEnd Then If CurY = WinEnd Then
ScreenRefreshFull TextRefreshFull
Else Begin Else Begin
Inc (CurY); Inc (CurY);
Inc (CurLine); Inc (CurLine);
@ -260,7 +261,7 @@ Begin
End; End;
If CurY = WinStart Then If CurY = WinStart Then
ScreenRefreshFull TextRefreshFull
Else Begin Else Begin
Dec (CurY); Dec (CurY);
Dec (CurLine); Dec (CurLine);
@ -289,7 +290,7 @@ Begin
DeleteLine (CurLine); DeleteLine (CurLine);
Dec (CurLine); Dec (CurLine);
Dec (CurY); Dec (CurY);
If CurY < WinStart Then ScreenRefreshFull Else ScreenRefreshPart; If CurY < WinStart Then TextRefreshFull Else TextRefreshPart;
End Else End Else
If Pos(' ', Session.Msgs.MsgText[CurLine]) > 0 Then Begin If Pos(' ', Session.Msgs.MsgText[CurLine]) > 0 Then Begin
For A := Length(Session.Msgs.MsgText[CurLine]) DownTo 1 Do For A := Length(Session.Msgs.MsgText[CurLine]) DownTo 1 Do
@ -299,9 +300,10 @@ Begin
Delete (Session.Msgs.MsgText[CurLine], 1, A); Delete (Session.Msgs.MsgText[CurLine], 1, A);
Dec (CurLine); Dec (CurLine);
Dec (CurY); Dec (CurY);
If CurY < WinStart Then ScreenRefreshFull Else ScreenRefreshPart; If CurY < WinStart Then TextRefreshFull Else TextRefreshPart;
Exit; Exit;
End; End;
keyUpArrow(True); keyUpArrow(True);
End; End;
End; End;
@ -318,7 +320,7 @@ End;
Procedure keyRightArrow; Procedure keyRightArrow;
Begin Begin
if curx < length(Session.Msgs.MsgText[curline])+1 then begin If CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Then Begin
Inc (CurX); Inc (CurX);
UpdatePosition; UpdatePosition;
End Else Begin End Else Begin
@ -331,13 +333,17 @@ Procedure AddChar (Ch: Char);
Begin Begin
If InsertMode Then Begin If InsertMode Then Begin
Insert (Ch, Session.Msgs.MsgText[Curline], CurX); Insert (Ch, Session.Msgs.MsgText[Curline], CurX);
Print (Copy(Session.Msgs.MsgText[CurLine], CurX, Length(Session.Msgs.MsgText[CurLine]))); Print (Copy(Session.Msgs.MsgText[CurLine], CurX, Length(Session.Msgs.MsgText[CurLine])));
End Else Begin End Else Begin
If CurX > Length(Session.Msgs.MsgText[CurLine]) Then Inc(Session.Msgs.MsgText[CurLine][0]); If CurX > Length(Session.Msgs.MsgText[CurLine]) Then
Inc(Session.Msgs.MsgText[CurLine][0]);
Session.Msgs.MsgText[CurLine][CurX] := Ch; Session.Msgs.MsgText[CurLine][CurX] := Ch;
Print (Ch); {outchar} Print (Ch);
End; End;
Inc (CurX); Inc (CurX);
UpdatePosition; UpdatePosition;
End; End;
@ -350,8 +356,8 @@ Begin
If InsertMode Then Print('INS') else Print('OVR'); { ++lang } If InsertMode Then Print('INS') else Print('OVR'); { ++lang }
Session.io.AnsiGotoXY (CurX, CurY); Session.io.AnsiGotoXY (CurX, CurY);
Session.io.AnsiColor (tColor); Session.io.AnsiColor (WinText);
End; End;
Procedure FullReDraw; Procedure FullReDraw;
@ -360,11 +366,11 @@ Begin
WinStart := Session.io.ScreenInfo[1].Y; WinStart := Session.io.ScreenInfo[1].Y;
WinEnd := Session.io.ScreenInfo[2].Y; WinEnd := Session.io.ScreenInfo[2].Y;
tColor := Session.io.ScreenInfo[1].A; WinText := Session.io.ScreenInfo[1].A;
ToggleInsert (False); ToggleInsert (False);
ScreenRefreshFull; TextRefreshFull;
End; End;
Procedure Quote; Procedure Quote;
@ -384,7 +390,7 @@ Begin
Exit; Exit;
End; End;
NumLines := 0; NumLines := 0;
Session.io.AllowPause := True; Session.io.AllowPause := True;
While Not Eof(InFile) Do Begin While Not Eof(InFile) Do Begin
@ -422,14 +428,17 @@ Begin
If (Start > 0) and (Start <= NumLines) and (Finish <= NumLines) Then Begin If (Start > 0) and (Start <= NumLines) and (Finish <= NumLines) Then Begin
If Finish = 0 Then Finish := Start; If Finish = 0 Then Finish := Start;
For NumLines := Start to Finish Do Begin For NumLines := Start to Finish Do Begin
If TotalLine = mysMaxMsgLines Then Break; If TotalLine = mysMaxMsgLines Then Break;
If Session.Msgs.MsgText[CurLine] <> '' Then Begin If Session.Msgs.MsgText[CurLine] <> '' Then Begin
Inc (CurLine); Inc (CurLine);
InsertLine (CurLine); InsertLine (CurLine);
End; End;
Session.Msgs.MsgText[CurLine] := Text[NumLines]; Session.Msgs.MsgText[CurLine] := Text[NumLines];
End; End;
If CurLine < MaxLines then Inc(CurLine); If CurLine < MaxLines then Inc(CurLine);
End; End;
@ -461,11 +470,13 @@ Var
Begin Begin
Session.io.AnsiGotoXY (1, Session.io.ScreenInfo[2].Y); Session.io.AnsiGotoXY (1, Session.io.ScreenInfo[2].Y);
Session.io.AnsiColor (Session.io.ScreenInfo[2].A); Session.io.AnsiColor (Session.io.ScreenInfo[2].A);
For A := QuoteTopPage to QuoteTopPage + 5 Do Begin For A := QuoteTopPage to QuoteTopPage + 5 Do Begin
If A <= QuoteLines Then Print (QText[A]); If A <= QuoteLines Then Print (QText[A]);
Session.io.AnsiClrEOL; Session.io.AnsiClrEOL;
If A <= QuoteLines Then PrintLn(''); If A <= QuoteLines Then PrintLn('');
End; End;
UpdateBar(True); UpdateBar(True);
End; End;
@ -495,10 +506,10 @@ Begin
Session.io.OutFile ('ansiquot', True, 0); Session.io.OutFile ('ansiquot', True, 0);
If CurY >= Session.io.ScreenInfo[1].Y Then Begin If CurY >= Session.io.ScreenInfo[1].Y Then Begin
Session.io.AnsiColor(tColor); Session.io.AnsiColor(WinText);
Temp1 := WinEnd; Temp1 := WinEnd;
WinEnd := Session.io.ScreenInfo[1].Y; WinEnd := Session.io.ScreenInfo[1].Y;
ScreenRefreshFull; TextRefreshFull;
WinEnd := Temp1; WinEnd := Temp1;
End; End;
@ -524,6 +535,7 @@ Begin
Dec (QuoteTopPage); Dec (QuoteTopPage);
UpdateWindow; UpdateWindow;
End; End;
NoMore := False; NoMore := False;
End; End;
#73, #73,
@ -534,7 +546,9 @@ Begin
QuoteTopPage := 1; QuoteTopPage := 1;
QuoteCurLine := 0; QuoteCurLine := 0;
End; End;
NoMore := False; NoMore := False;
UpdateWindow; UpdateWindow;
End; End;
#79 : Begin #79 : Begin
@ -584,19 +598,21 @@ Begin
Session.Msgs.MsgText[CurLine] := QText[QuoteTopPage + QuoteCurLine]; Session.Msgs.MsgText[CurLine] := QText[QuoteTopPage + QuoteCurLine];
Inc (CurLine); Inc (CurLine);
Session.io.AnsiColor(tColor); Session.io.AnsiColor(WinText);
Temp1 := WinEnd; Temp1 := WinEnd;
WinEnd := Session.io.ScreenInfo[1].Y; WinEnd := Session.io.ScreenInfo[1].Y;
If CurLine - Scroll + WinStart + 4 >= WinEnd Then Begin If CurLine - Scroll + WinStart + 4 >= WinEnd Then Begin
ScreenRefreshFull; TextRefreshFull;
Scroll := CurLine; Scroll := CurLine;
End Else Begin End Else Begin
Dec (CurLine); Dec (CurLine);
ScreenRefreshPart; TextRefreshPart;
Inc (CurLine); Inc (CurLine);
Inc (CurY); Inc (CurY);
End; End;
WinEnd := Temp1; WinEnd := Temp1;
If QuoteTopPage + QuoteCurLine < QuoteLines Then If QuoteTopPage + QuoteCurLine < QuoteLines Then
@ -611,7 +627,9 @@ Begin
End; End;
End; End;
Until False; Until False;
Session.io.OutFull('|16'); Session.io.OutFull('|16');
If (CurLine < mysMaxMsgLines) And Added Then Inc(CurLine); If (CurLine < mysMaxMsgLines) And Added Then Inc(CurLine);
End; End;
@ -625,7 +643,9 @@ Begin
Repeat Repeat
Session.io.OutFull (Session.GetPrompt(354)); Session.io.OutFull (Session.GetPrompt(354));
Ch := Session.io.OneKey ('?ACHQRSTU', True); Ch := Session.io.OneKey ('?ACHQRSTU', True);
Case Ch of Case Ch of
'?' : Session.io.OutFullLn (Session.GetPrompt(355)); '?' : Session.io.OutFullLn (Session.GetPrompt(355));
'A' : If Forced Then Begin 'A' : If Forced Then Begin
@ -675,7 +695,8 @@ Begin
Dec (CurLine, (WinEnd - WinStart)) {scroll one page up} Dec (CurLine, (WinEnd - WinStart)) {scroll one page up}
Else Else
CurLine := 1; CurLine := 1;
ScreenRefreshFull;
TextRefreshFull;
End; End;
End; End;
@ -688,7 +709,7 @@ Begin
Else Else
CurLine := TotalLine; CurLine := TotalLine;
ScreenRefreshFull; TextRefreshFull;
End; End;
End; End;
@ -748,19 +769,19 @@ Begin
If CurLine < TotalLine Then If CurLine < TotalLine Then
If (Session.Msgs.MsgText[CurLine] = '') and (TotalLine > 1) Then Begin If (Session.Msgs.MsgText[CurLine] = '') and (TotalLine > 1) Then Begin
DeleteLine (CurLine); DeleteLine (CurLine);
ScreenRefreshPart; TextRefreshPart;
End Else End Else
If TotalLine > 1 Then If TotalLine > 1 Then
If Length(Session.Msgs.MsgText[CurLine]) + Length(Session.Msgs.MsgText[CurLine + 1]) <= WrapPos Then Begin If Length(Session.Msgs.MsgText[CurLine]) + Length(Session.Msgs.MsgText[CurLine + 1]) <= WrapPos Then Begin
Session.Msgs.MsgText[CurLine] := Session.Msgs.MsgText[CurLine] + Session.Msgs.MsgText[CurLine + 1]; Session.Msgs.MsgText[CurLine] := Session.Msgs.MsgText[CurLine] + Session.Msgs.MsgText[CurLine + 1];
DeleteLine (CurLine + 1); DeleteLine (CurLine + 1);
ScreenRefreshPart; TextRefreshPart;
End Else End Else
For A := Length(Session.Msgs.MsgText[CurLine + 1]) DownTo 1 Do For A := Length(Session.Msgs.MsgText[CurLine + 1]) DownTo 1 Do
If (Session.Msgs.MsgText[CurLine + 1][A] = ' ') and (Length(Session.Msgs.MsgText[CurLine]) + A <= WrapPos) Then Begin If (Session.Msgs.MsgText[CurLine + 1][A] = ' ') and (Length(Session.Msgs.MsgText[CurLine]) + A <= WrapPos) Then Begin
Session.Msgs.MsgText[CurLine] := Session.Msgs.MsgText[CurLine] + Copy(Session.Msgs.MsgText[CurLine + 1], 1, A - 1); Session.Msgs.MsgText[CurLine] := Session.Msgs.MsgText[CurLine] + Copy(Session.Msgs.MsgText[CurLine + 1], 1, A - 1);
Delete (Session.Msgs.MsgText[CurLine + 1], 1, A); Delete (Session.Msgs.MsgText[CurLine + 1], 1, A);
ScreenRefreshPart; TextRefreshPart;
End; End;
End; End;
End Else End Else
@ -797,7 +818,7 @@ Begin
Session.io.AnsiClrEOL; Session.io.AnsiClrEOL;
End; End;
^K : ; // cuttext ^K : ; // cuttext... what will be copy?
^L, ^L,
^M : Begin ^M : Begin
Session.io.PurgeInputBuffer; Session.io.PurgeInputBuffer;
@ -818,15 +839,19 @@ Begin
FullReDraw; FullReDraw;
End; End;
^R : ; // paste ^R : ; // paste
^T : If CurX > 1 Then Begin ^T : Begin
While (CurX > 1) and (Session.Msgs.MsgText[CurLine][CurX] <> ' ') Do Dec(CurX); While CurX > 1 Do Begin
While (CurX > 1) and (Session.Msgs.MsgText[CurLine][CurX] = ' ') Do Dec(CurX); Dec (CurX);
While (CurX > 1) and (Session.Msgs.MsgText[CurLine][CurX] <> ' ') Do Dec(CurX);
If CurX > 1 Then Inc (CurX); If Session.Msgs.MsgText[CurLine][CurX] = ' ' Then Break;
End;
UpdatePosition; UpdatePosition;
End; End;
^W : While (CurX > 1) Do Begin
keyBackSpace;
If Session.Msgs.MsgText[CurLine][CurX] = ' ' Then Break;
End;
^U : Begin ^U : Begin
While CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Do Begin While CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Do Begin
Inc (CurX); Inc (CurX);
@ -840,11 +865,11 @@ Begin
UpdatePosition; UpdatePosition;
End; End;
^V : ToggleInsert (True); ^V : ToggleInsert (True);
^W : ; // delete word left // ^W : ; // delete word left
^X : keyDownArrow; ^X : keyDownArrow;
^Y : Begin ^Y : Begin
DeleteLine (curline); DeleteLine (curline);
ScreenRefreshPart; TextRefreshPart;
End; End;
^[ : Begin ^[ : Begin
Commands; Commands;
@ -863,7 +888,9 @@ Begin
End Else End Else
If (CurX = 1) and (Ch = '/') Then Begin If (CurX = 1) and (Ch = '/') Then Begin
Commands; Commands;
If (Not Save) and (Not Done) Then FullReDraw; If (Not Save) and (Not Done) Then FullReDraw;
Session.io.AllowArrow := True; Session.io.AllowArrow := True;
End Else End Else
AddChar (Ch); AddChar (Ch);
@ -875,10 +902,12 @@ Begin
If Save Then Begin If Save Then Begin
A := TotalLine; A := TotalLine;
While (Session.Msgs.MsgText[A] = '') and (A > 1) Do Begin While (Session.Msgs.MsgText[A] = '') and (A > 1) Do Begin
Dec(A); Dec(A);
Dec(TotalLine); Dec(TotalLine);
End; End;
Lines := TotalLine; Lines := TotalLine;
End; End;