ANSI listbox search revamp
This commit is contained in:
parent
e1c55483f9
commit
d5455d46a5
|
@ -12,7 +12,19 @@ Procedure WriteXYPipe (X, Y, A, SZ : Byte; S: String);
|
|||
Function InXY (X, Y, Field, Max, Mode: Byte; Default: String) : String;
|
||||
Function InBox (Header, Text, Def: String; Len, MaxLen: Byte) : String;
|
||||
Procedure VerticalLine (X, Y1, Y2 : Byte);
|
||||
Function ShowMsgBox (BoxType : Byte; Str : String) : Boolean;
|
||||
Function ShowMsgBox (BoxType: Byte; Str: String) : Boolean;
|
||||
Procedure DefListBoxSearch (Var Owner: Pointer; Str: String);
|
||||
|
||||
Const
|
||||
BoxFrameType : Array[1..8] of String[8] =
|
||||
('ÚÄ¿³³ÀÄÙ',
|
||||
'ÉÍ»ººÈͼ',
|
||||
'ÖÄ·ººÓĽ',
|
||||
'Õ͸³³Ô;',
|
||||
'ÛßÛÛÛÛÜÛ',
|
||||
'ÛßÜÛÛßÜÛ',
|
||||
' ',
|
||||
'.-.||`-''');
|
||||
|
||||
Type
|
||||
TAnsiMenuBox = Class
|
||||
|
@ -40,6 +52,7 @@ Type
|
|||
End;
|
||||
|
||||
TAnsiMenuListStatusProc = Procedure (Num: Word; Str: String);
|
||||
TAnsiMenuListSearchProc = Procedure (Var Owner: Pointer; Str: String);
|
||||
|
||||
TAnsiMenuListBoxRec = Record
|
||||
Name : String;
|
||||
|
@ -73,6 +86,10 @@ Type
|
|||
Y1 : Byte;
|
||||
NoInput : Boolean;
|
||||
LastBarPos : Byte;
|
||||
SearchProc : TAnsiMenuListSearchProc;
|
||||
SearchX : Byte;
|
||||
SearchY : Byte;
|
||||
SearchA : Byte;
|
||||
|
||||
Constructor Create;
|
||||
Destructor Destroy; Override;
|
||||
|
@ -81,6 +98,7 @@ Type
|
|||
Procedure Add (Str: String; B: Byte);
|
||||
Procedure Get (Num: Word; Var Str: String; Var B: Boolean);
|
||||
Procedure SetStatusProc (P: TAnsiMenuListStatusProc);
|
||||
Procedure SetSearchProc (P: TAnsiMenuListSearchProc);
|
||||
Procedure Clear;
|
||||
Procedure Delete (RecPos : Word);
|
||||
Procedure UpdatePercent;
|
||||
|
@ -157,6 +175,26 @@ Begin
|
|||
Session.io.BufFlush;
|
||||
End;
|
||||
|
||||
Procedure DefListBoxSearch (Var Owner: Pointer; Str: String);
|
||||
Begin
|
||||
If Str = '' Then
|
||||
Str := strRep(BoxFrameType[TAnsiMenuList(Owner).Box.FrameType][7], 17)
|
||||
Else Begin
|
||||
If Length(Str) > 15 Then
|
||||
Str := Copy(Str, Length(Str) - 15 + 1, 255);
|
||||
|
||||
Str := '[' + strLower(Str) + ']';
|
||||
|
||||
While Length(Str) < 17 Do
|
||||
Str := Str + BoxFrameType[TAnsiMenuList(Owner).Box.FrameType][7];
|
||||
End;
|
||||
|
||||
WriteXY (TAnsiMenuList(Owner).SearchX,
|
||||
TAnsiMenuList(Owner).SearchY,
|
||||
TAnsiMenuList(Owner).SearchA,
|
||||
Str);
|
||||
End;
|
||||
|
||||
Function InBox (Header, Text, Def: String; Len, MaxLen: Byte) : String;
|
||||
Var
|
||||
Box : TAnsiMenuBox;
|
||||
|
@ -309,16 +347,6 @@ Begin
|
|||
End;
|
||||
|
||||
Procedure TAnsiMenuBox.Open (X1, Y1, X2, Y2: Byte);
|
||||
Const
|
||||
BF : Array[1..8] of String[8] =
|
||||
('ÚÄ¿³³ÀÄÙ',
|
||||
'ÉÍ»ººÈͼ',
|
||||
'ÖÄ·ººÓĽ',
|
||||
'Õ͸³³Ô;',
|
||||
'ÛßÛÛÛÛÜÛ',
|
||||
'ÛßÜÛÛßÜÛ',
|
||||
' ',
|
||||
'.-.||`-''');
|
||||
Var
|
||||
A : Integer;
|
||||
B : Integer;
|
||||
|
@ -340,16 +368,16 @@ Begin
|
|||
BoxAttr4 := BoxAttr;
|
||||
End;
|
||||
|
||||
WriteXY (X1, Y1, BoxAttr, BF[FrameType][1] + strRep(BF[FrameType][2], B));
|
||||
WriteXY (X2, Y1, BoxAttr4, BF[FrameType][3]);
|
||||
WriteXY (X1, Y1, BoxAttr, BoxFrameType[FrameType][1] + strRep(BoxFrameType[FrameType][2], B));
|
||||
WriteXY (X2, Y1, BoxAttr4, BoxFrameType[FrameType][3]);
|
||||
|
||||
For A := Y1 + 1 To Y2 - 1 Do Begin
|
||||
WriteXY (X1, A, BoxAttr, BF[FrameType][4] + strRep(' ', B));
|
||||
WriteXY (X2, A, BoxAttr2, BF[FrameType][5]);
|
||||
WriteXY (X1, A, BoxAttr, BoxFrameType[FrameType][4] + strRep(' ', B));
|
||||
WriteXY (X2, A, BoxAttr2, BoxFrameType[FrameType][5]);
|
||||
End;
|
||||
|
||||
WriteXY (X1, Y2, BoxAttr3, BF[FrameType][6]);
|
||||
WriteXY (X1+1, Y2, BoxAttr2, strRep(BF[FrameType][7], B) + BF[FrameType][8]);
|
||||
WriteXY (X1, Y2, BoxAttr3, BoxFrameType[FrameType][6]);
|
||||
WriteXY (X1+1, Y2, BoxAttr2, strRep(BoxFrameType[FrameType][7], B) + BoxFrameType[FrameType][8]);
|
||||
|
||||
If Header <> '' Then
|
||||
Case HeadType of
|
||||
|
@ -414,7 +442,7 @@ Begin
|
|||
NoWindow := False;
|
||||
AllowTag := False;
|
||||
TagChar := '*';
|
||||
TagKey := #32;
|
||||
TagKey := #09;
|
||||
TagPos := 0;
|
||||
TagAttr := 15 + 7 * 16;
|
||||
Marked := 0;
|
||||
|
@ -422,6 +450,10 @@ Begin
|
|||
NoInput := False;
|
||||
LastBarPos := 0;
|
||||
StatusProc := NIL;
|
||||
SearchProc := DefListBoxSearch;
|
||||
SearchX := 0;
|
||||
SearchY := 0;
|
||||
SearchA := 0;
|
||||
|
||||
Session.io.BufFlush;
|
||||
End;
|
||||
|
@ -562,12 +594,16 @@ Var
|
|||
First : Boolean;
|
||||
SavedRec : Word;
|
||||
SavedTop : Word;
|
||||
SearchStr : String[80];
|
||||
SearchStr : String;
|
||||
LastWasChar : Boolean;
|
||||
Begin
|
||||
If Not NoWindow Then
|
||||
Box.Open (BX1, BY1, BX2, BY2);
|
||||
|
||||
If SearchX = 0 Then SearchX := BX1 + 2;
|
||||
If SearchY = 0 Then SearchY := BY2;
|
||||
If SearchA = 0 Then SearchA := Box.BoxAttr4;
|
||||
|
||||
X1 := BX1;
|
||||
Y1 := BY1;
|
||||
|
||||
|
@ -589,11 +625,15 @@ Begin
|
|||
Update;
|
||||
|
||||
LastWasChar := False;
|
||||
SearchStr := '';
|
||||
|
||||
Repeat
|
||||
If Not LastWasChar Then
|
||||
If Not LastWasChar Then Begin
|
||||
If Assigned(SearchProc) And (SearchStr <> '') Then
|
||||
SearchProc (Self, '');
|
||||
|
||||
SearchStr := ''
|
||||
Else
|
||||
End Else
|
||||
LastWasChar := False;
|
||||
|
||||
If Assigned(StatusProc) Then
|
||||
|
@ -678,20 +718,40 @@ Begin
|
|||
ExitCode := Ch;
|
||||
Exit;
|
||||
End Else Begin
|
||||
If Ch <> #01 Then Begin
|
||||
If Ch = #25 Then Begin
|
||||
LastWasChar := False;
|
||||
Continue;
|
||||
End;
|
||||
|
||||
If Ch = #8 Then Begin
|
||||
If Length(SearchStr) > 0 Then
|
||||
Dec(SearchStr[0])
|
||||
Else
|
||||
Continue;
|
||||
End Else
|
||||
If Ord(Ch) < 32 Then
|
||||
Continue
|
||||
Else
|
||||
SearchStr := SearchStr + UpCase(Ch);
|
||||
End;
|
||||
|
||||
SavedTop := TopPage;
|
||||
SavedRec := Picked;
|
||||
LastWasChar := True;
|
||||
SearchStr := SearchStr + UpCase(Ch);
|
||||
First := True;
|
||||
StartPos := Picked + 1;
|
||||
EndPos := ListMax;
|
||||
|
||||
If Assigned(SearchProc) Then
|
||||
SearchProc(Self, SearchStr);
|
||||
|
||||
If StartPos > ListMax Then StartPos := 1;
|
||||
|
||||
Count := StartPos;
|
||||
|
||||
While (Count <= EndPos) Do Begin
|
||||
If strUpper(Copy(List[Count]^.Name, 1, Length(SearchStr))) = SearchStr Then Begin
|
||||
If Pos(strUpper(SearchStr), strUpper(List[Count]^.Name)) > 0 Then Begin
|
||||
|
||||
While Count <> Picked Do Begin
|
||||
If Picked < Count Then Begin
|
||||
|
@ -755,7 +815,12 @@ Begin
|
|||
End;
|
||||
End;
|
||||
|
||||
Procedure TAnsiMenuList.SetStatusProc (P : TAnsiMenuListStatusProc);
|
||||
Procedure TAnsiMenuList.SetSearchProc (P: TAnsiMenuListSearchProc);
|
||||
Begin
|
||||
SearchProc := P;
|
||||
End;
|
||||
|
||||
Procedure TAnsiMenuList.SetStatusProc (P: TAnsiMenuListStatusProc);
|
||||
Begin
|
||||
StatusProc := P;
|
||||
End;
|
||||
|
|
|
@ -91,6 +91,7 @@ Begin
|
|||
Box.Header := ' Archive Editor ';
|
||||
List.NoWindow := True;
|
||||
List.LoChars := #13#27#47;
|
||||
List.SearchY := 20;
|
||||
|
||||
Box.Open (13, 5, 67, 20);
|
||||
|
||||
|
|
|
@ -121,6 +121,7 @@ Begin
|
|||
List.NoWindow := True;
|
||||
List.LoChars := #13#27#47;
|
||||
List.AllowTag := True;
|
||||
List.SearchY := 21;
|
||||
|
||||
If FBaseFile.FileSize = 0 Then InsertRecord;
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ Begin
|
|||
List := TAnsiMenuList.Create;
|
||||
|
||||
List.NoWindow := True;
|
||||
List.SearchY := 20;
|
||||
List.LoChars := #13#27#47;
|
||||
|
||||
If Msg Then
|
||||
|
|
|
@ -339,6 +339,7 @@ Begin
|
|||
List.LoAttr := 113;
|
||||
List.NoInput := True;
|
||||
List.NoWindow := True;
|
||||
List.SearchY := 21;
|
||||
Box.Shadow := False;
|
||||
Box.Header := ' Command #' + strI2S(Num) + ' (' + MenuName + ') ';
|
||||
Topic := '|03(|09Menu Editor|03) |01-|09> |15';
|
||||
|
@ -372,7 +373,7 @@ Begin
|
|||
Form.AddBol ('W', ' Redraw' , 33, 14, 43, 14, 8, 3, @Menu.Item[Num]^.ReDraw, Topic + 'Redraw menu after running this command?');
|
||||
|
||||
Form.AddByte ('U', ' Up' , 56, 10, 62, 10, 4, 3, 0, 255, @Menu.Item[Num]^.JumpUp, Topic + Grid + 'UP');
|
||||
Form.AddByte ('D', ' Down' , 54, 11, 62, 11, 6, 3, 0, 255, @Menu.Item[Num]^.JumpDown, Topic + Grid + 'DOWN');
|
||||
Form.AddByte (#01, ' Down' , 54, 11, 62, 11, 6, 3, 0, 255, @Menu.Item[Num]^.JumpDown, Topic + Grid + 'DOWN');
|
||||
Form.AddByte ('L', ' Left' , 54, 12, 62, 12, 6, 3, 0, 255, @Menu.Item[Num]^.JumpLeft, Topic + Grid + 'LEFT');
|
||||
Form.AddByte ('R', ' Right' , 53, 13, 62, 13, 7, 3, 0, 255, @Menu.Item[Num]^.JumpRight, Topic + Grid + 'RIGHT');
|
||||
Form.AddByte ('E', ' Home' , 54, 14, 62, 14, 6, 3, 0, 255, @Menu.Item[Num]^.JumpHome, Topic + Grid + 'HOME');
|
||||
|
@ -495,6 +496,7 @@ Begin
|
|||
|
||||
List.NoWindow := True;
|
||||
List.LoChars := #13#27#47;
|
||||
List.SearchY := 21;
|
||||
Box.Header := ' Command list (' + MenuName + ') ';
|
||||
|
||||
Box.Open (9, 5, 72, 21);
|
||||
|
@ -658,6 +660,7 @@ Begin
|
|||
|
||||
List.NoWindow := True;
|
||||
List.LoChars := #13#27#47;
|
||||
List.SearchY := 21;
|
||||
Box.Header := ' Menu Editor (' + Session.Theme.Desc + ') ';
|
||||
|
||||
Box.Open (12, 5, 68, 21);
|
||||
|
|
|
@ -183,6 +183,7 @@ Begin
|
|||
List.NoWindow := True;
|
||||
List.LoChars := #13#27#47;
|
||||
List.AllowTag := True;
|
||||
List.SearchY := 21;
|
||||
|
||||
If MBaseFile.FileSize = 0 Then AssignRecord(True);
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ Begin
|
|||
Box.Header := ' Protocol Editor ';
|
||||
List.NoWindow := True;
|
||||
List.LoChars := #13#27#47;
|
||||
List.SearchY := 20;
|
||||
|
||||
Box.Open (13, 5, 67, 20);
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ Begin
|
|||
Box.Header := ' Security Levels ';
|
||||
List.LoChars := #13#27#47;
|
||||
List.NoWindow := True;
|
||||
List.SearchY := 21;
|
||||
|
||||
Box.Open (21, 5, 59, 21);
|
||||
|
||||
|
|
|
@ -544,6 +544,8 @@ Begin
|
|||
Box := TAnsiMenuBox.Create;
|
||||
Form := TAnsiMenuForm.Create;
|
||||
|
||||
Box.Header := ' Message Base Settings ';
|
||||
|
||||
Box.Open (4, 5, 77, 19);
|
||||
|
||||
VerticalLine (27, 7, 17);
|
||||
|
@ -588,6 +590,8 @@ Begin
|
|||
Box := TAnsiMenuBox.Create;
|
||||
Form := TAnsiMenuForm.Create;
|
||||
|
||||
Box.Header := ' New User Settings 1 ';
|
||||
|
||||
Box.Open (18, 5, 63, 16);
|
||||
|
||||
VerticalLine (39, 7, 14);
|
||||
|
@ -619,6 +623,8 @@ Begin
|
|||
Box := TAnsiMenuBox.Create;
|
||||
Form := TAnsiMenuForm.Create;
|
||||
|
||||
Box.Header := ' New User Settings 2 ';
|
||||
|
||||
Box.Open (8, 5, 73, 21);
|
||||
|
||||
VerticalLine (25, 7, 19);
|
||||
|
@ -668,6 +674,8 @@ Begin
|
|||
Box := TAnsiMenuBox.Create;
|
||||
Form := TAnsiMenuForm.Create;
|
||||
|
||||
Box.Header := ' Console Settings ';
|
||||
|
||||
Box.Open (5, 5, 76, 16);
|
||||
|
||||
VerticalLine (17, 7, 14);
|
||||
|
@ -688,5 +696,4 @@ Begin
|
|||
Box.Free;
|
||||
End;
|
||||
|
||||
|
||||
End.
|
||||
|
|
|
@ -715,6 +715,7 @@ Begin
|
|||
Box.Header := ' Themes ';
|
||||
List.LoChars := #13#27#47;
|
||||
List.NoWindow := True;
|
||||
List.SearchY := 19;
|
||||
|
||||
Box.Open (8, 6, 73, 19);
|
||||
|
||||
|
@ -846,4 +847,4 @@ Begin
|
|||
ThemeFile.Free;
|
||||
End;
|
||||
|
||||
End.
|
||||
End.
|
||||
|
|
Loading…
Reference in New Issue