ANSI listbox search revamp

This commit is contained in:
mysticbbs 2012-08-04 19:18:48 -04:00
parent e1c55483f9
commit d5455d46a5
10 changed files with 109 additions and 27 deletions

View File

@ -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 InXY (X, Y, Field, Max, Mode: Byte; Default: String) : String;
Function InBox (Header, Text, Def: String; Len, MaxLen: Byte) : String; Function InBox (Header, Text, Def: String; Len, MaxLen: Byte) : String;
Procedure VerticalLine (X, Y1, Y2 : Byte); 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 Type
TAnsiMenuBox = Class TAnsiMenuBox = Class
@ -40,6 +52,7 @@ Type
End; End;
TAnsiMenuListStatusProc = Procedure (Num: Word; Str: String); TAnsiMenuListStatusProc = Procedure (Num: Word; Str: String);
TAnsiMenuListSearchProc = Procedure (Var Owner: Pointer; Str: String);
TAnsiMenuListBoxRec = Record TAnsiMenuListBoxRec = Record
Name : String; Name : String;
@ -73,6 +86,10 @@ Type
Y1 : Byte; Y1 : Byte;
NoInput : Boolean; NoInput : Boolean;
LastBarPos : Byte; LastBarPos : Byte;
SearchProc : TAnsiMenuListSearchProc;
SearchX : Byte;
SearchY : Byte;
SearchA : Byte;
Constructor Create; Constructor Create;
Destructor Destroy; Override; Destructor Destroy; Override;
@ -81,6 +98,7 @@ Type
Procedure Add (Str: String; B: Byte); Procedure Add (Str: String; B: Byte);
Procedure Get (Num: Word; Var Str: String; Var B: Boolean); Procedure Get (Num: Word; Var Str: String; Var B: Boolean);
Procedure SetStatusProc (P: TAnsiMenuListStatusProc); Procedure SetStatusProc (P: TAnsiMenuListStatusProc);
Procedure SetSearchProc (P: TAnsiMenuListSearchProc);
Procedure Clear; Procedure Clear;
Procedure Delete (RecPos : Word); Procedure Delete (RecPos : Word);
Procedure UpdatePercent; Procedure UpdatePercent;
@ -157,6 +175,26 @@ Begin
Session.io.BufFlush; Session.io.BufFlush;
End; 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; Function InBox (Header, Text, Def: String; Len, MaxLen: Byte) : String;
Var Var
Box : TAnsiMenuBox; Box : TAnsiMenuBox;
@ -309,16 +347,6 @@ Begin
End; End;
Procedure TAnsiMenuBox.Open (X1, Y1, X2, Y2: Byte); Procedure TAnsiMenuBox.Open (X1, Y1, X2, Y2: Byte);
Const
BF : Array[1..8] of String[8] =
('ÚÄ¿³³ÀÄÙ',
'ÉÍ»ººÈͼ',
'ÖÄ·ººÓĽ',
'Õ͸³³Ô;',
'ÛßÛÛÛÛÜÛ',
'ÛßÜÛÛßÜÛ',
' ',
'.-.||`-''');
Var Var
A : Integer; A : Integer;
B : Integer; B : Integer;
@ -340,16 +368,16 @@ Begin
BoxAttr4 := BoxAttr; BoxAttr4 := BoxAttr;
End; End;
WriteXY (X1, Y1, BoxAttr, BF[FrameType][1] + strRep(BF[FrameType][2], B)); WriteXY (X1, Y1, BoxAttr, BoxFrameType[FrameType][1] + strRep(BoxFrameType[FrameType][2], B));
WriteXY (X2, Y1, BoxAttr4, BF[FrameType][3]); WriteXY (X2, Y1, BoxAttr4, BoxFrameType[FrameType][3]);
For A := Y1 + 1 To Y2 - 1 Do Begin For A := Y1 + 1 To Y2 - 1 Do Begin
WriteXY (X1, A, BoxAttr, BF[FrameType][4] + strRep(' ', B)); WriteXY (X1, A, BoxAttr, BoxFrameType[FrameType][4] + strRep(' ', B));
WriteXY (X2, A, BoxAttr2, BF[FrameType][5]); WriteXY (X2, A, BoxAttr2, BoxFrameType[FrameType][5]);
End; End;
WriteXY (X1, Y2, BoxAttr3, BF[FrameType][6]); WriteXY (X1, Y2, BoxAttr3, BoxFrameType[FrameType][6]);
WriteXY (X1+1, Y2, BoxAttr2, strRep(BF[FrameType][7], B) + BF[FrameType][8]); WriteXY (X1+1, Y2, BoxAttr2, strRep(BoxFrameType[FrameType][7], B) + BoxFrameType[FrameType][8]);
If Header <> '' Then If Header <> '' Then
Case HeadType of Case HeadType of
@ -414,7 +442,7 @@ Begin
NoWindow := False; NoWindow := False;
AllowTag := False; AllowTag := False;
TagChar := '*'; TagChar := '*';
TagKey := #32; TagKey := #09;
TagPos := 0; TagPos := 0;
TagAttr := 15 + 7 * 16; TagAttr := 15 + 7 * 16;
Marked := 0; Marked := 0;
@ -422,6 +450,10 @@ Begin
NoInput := False; NoInput := False;
LastBarPos := 0; LastBarPos := 0;
StatusProc := NIL; StatusProc := NIL;
SearchProc := DefListBoxSearch;
SearchX := 0;
SearchY := 0;
SearchA := 0;
Session.io.BufFlush; Session.io.BufFlush;
End; End;
@ -562,12 +594,16 @@ Var
First : Boolean; First : Boolean;
SavedRec : Word; SavedRec : Word;
SavedTop : Word; SavedTop : Word;
SearchStr : String[80]; SearchStr : String;
LastWasChar : Boolean; LastWasChar : Boolean;
Begin Begin
If Not NoWindow Then If Not NoWindow Then
Box.Open (BX1, BY1, BX2, BY2); 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; X1 := BX1;
Y1 := BY1; Y1 := BY1;
@ -589,11 +625,15 @@ Begin
Update; Update;
LastWasChar := False; LastWasChar := False;
SearchStr := '';
Repeat Repeat
If Not LastWasChar Then If Not LastWasChar Then Begin
If Assigned(SearchProc) And (SearchStr <> '') Then
SearchProc (Self, '');
SearchStr := '' SearchStr := ''
Else End Else
LastWasChar := False; LastWasChar := False;
If Assigned(StatusProc) Then If Assigned(StatusProc) Then
@ -678,20 +718,40 @@ Begin
ExitCode := Ch; ExitCode := Ch;
Exit; Exit;
End Else Begin 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; SavedTop := TopPage;
SavedRec := Picked; SavedRec := Picked;
LastWasChar := True; LastWasChar := True;
SearchStr := SearchStr + UpCase(Ch);
First := True; First := True;
StartPos := Picked + 1; StartPos := Picked + 1;
EndPos := ListMax; EndPos := ListMax;
If Assigned(SearchProc) Then
SearchProc(Self, SearchStr);
If StartPos > ListMax Then StartPos := 1; If StartPos > ListMax Then StartPos := 1;
Count := StartPos; Count := StartPos;
While (Count <= EndPos) Do Begin 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 While Count <> Picked Do Begin
If Picked < Count Then Begin If Picked < Count Then Begin
@ -755,7 +815,12 @@ Begin
End; End;
End; End;
Procedure TAnsiMenuList.SetStatusProc (P : TAnsiMenuListStatusProc); Procedure TAnsiMenuList.SetSearchProc (P: TAnsiMenuListSearchProc);
Begin
SearchProc := P;
End;
Procedure TAnsiMenuList.SetStatusProc (P: TAnsiMenuListStatusProc);
Begin Begin
StatusProc := P; StatusProc := P;
End; End;

View File

@ -91,6 +91,7 @@ Begin
Box.Header := ' Archive Editor '; Box.Header := ' Archive Editor ';
List.NoWindow := True; List.NoWindow := True;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.SearchY := 20;
Box.Open (13, 5, 67, 20); Box.Open (13, 5, 67, 20);

View File

@ -121,6 +121,7 @@ Begin
List.NoWindow := True; List.NoWindow := True;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.AllowTag := True; List.AllowTag := True;
List.SearchY := 21;
If FBaseFile.FileSize = 0 Then InsertRecord; If FBaseFile.FileSize = 0 Then InsertRecord;

View File

@ -82,6 +82,7 @@ Begin
List := TAnsiMenuList.Create; List := TAnsiMenuList.Create;
List.NoWindow := True; List.NoWindow := True;
List.SearchY := 20;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
If Msg Then If Msg Then

View File

@ -339,6 +339,7 @@ Begin
List.LoAttr := 113; List.LoAttr := 113;
List.NoInput := True; List.NoInput := True;
List.NoWindow := True; List.NoWindow := True;
List.SearchY := 21;
Box.Shadow := False; Box.Shadow := False;
Box.Header := ' Command #' + strI2S(Num) + ' (' + MenuName + ') '; Box.Header := ' Command #' + strI2S(Num) + ' (' + MenuName + ') ';
Topic := '|03(|09Menu Editor|03) |01-|09> |15'; 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.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 ('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 ('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 ('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'); 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.NoWindow := True;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.SearchY := 21;
Box.Header := ' Command list (' + MenuName + ') '; Box.Header := ' Command list (' + MenuName + ') ';
Box.Open (9, 5, 72, 21); Box.Open (9, 5, 72, 21);
@ -658,6 +660,7 @@ Begin
List.NoWindow := True; List.NoWindow := True;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.SearchY := 21;
Box.Header := ' Menu Editor (' + Session.Theme.Desc + ') '; Box.Header := ' Menu Editor (' + Session.Theme.Desc + ') ';
Box.Open (12, 5, 68, 21); Box.Open (12, 5, 68, 21);

View File

@ -183,6 +183,7 @@ Begin
List.NoWindow := True; List.NoWindow := True;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.AllowTag := True; List.AllowTag := True;
List.SearchY := 21;
If MBaseFile.FileSize = 0 Then AssignRecord(True); If MBaseFile.FileSize = 0 Then AssignRecord(True);

View File

@ -92,6 +92,7 @@ Begin
Box.Header := ' Protocol Editor '; Box.Header := ' Protocol Editor ';
List.NoWindow := True; List.NoWindow := True;
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.SearchY := 20;
Box.Open (13, 5, 67, 20); Box.Open (13, 5, 67, 20);

View File

@ -100,6 +100,7 @@ Begin
Box.Header := ' Security Levels '; Box.Header := ' Security Levels ';
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.NoWindow := True; List.NoWindow := True;
List.SearchY := 21;
Box.Open (21, 5, 59, 21); Box.Open (21, 5, 59, 21);

View File

@ -544,6 +544,8 @@ Begin
Box := TAnsiMenuBox.Create; Box := TAnsiMenuBox.Create;
Form := TAnsiMenuForm.Create; Form := TAnsiMenuForm.Create;
Box.Header := ' Message Base Settings ';
Box.Open (4, 5, 77, 19); Box.Open (4, 5, 77, 19);
VerticalLine (27, 7, 17); VerticalLine (27, 7, 17);
@ -588,6 +590,8 @@ Begin
Box := TAnsiMenuBox.Create; Box := TAnsiMenuBox.Create;
Form := TAnsiMenuForm.Create; Form := TAnsiMenuForm.Create;
Box.Header := ' New User Settings 1 ';
Box.Open (18, 5, 63, 16); Box.Open (18, 5, 63, 16);
VerticalLine (39, 7, 14); VerticalLine (39, 7, 14);
@ -619,6 +623,8 @@ Begin
Box := TAnsiMenuBox.Create; Box := TAnsiMenuBox.Create;
Form := TAnsiMenuForm.Create; Form := TAnsiMenuForm.Create;
Box.Header := ' New User Settings 2 ';
Box.Open (8, 5, 73, 21); Box.Open (8, 5, 73, 21);
VerticalLine (25, 7, 19); VerticalLine (25, 7, 19);
@ -668,6 +674,8 @@ Begin
Box := TAnsiMenuBox.Create; Box := TAnsiMenuBox.Create;
Form := TAnsiMenuForm.Create; Form := TAnsiMenuForm.Create;
Box.Header := ' Console Settings ';
Box.Open (5, 5, 76, 16); Box.Open (5, 5, 76, 16);
VerticalLine (17, 7, 14); VerticalLine (17, 7, 14);
@ -688,5 +696,4 @@ Begin
Box.Free; Box.Free;
End; End;
End. End.

View File

@ -715,6 +715,7 @@ Begin
Box.Header := ' Themes '; Box.Header := ' Themes ';
List.LoChars := #13#27#47; List.LoChars := #13#27#47;
List.NoWindow := True; List.NoWindow := True;
List.SearchY := 19;
Box.Open (8, 6, 73, 19); Box.Open (8, 6, 73, 19);
@ -846,4 +847,4 @@ Begin
ThemeFile.Free; ThemeFile.Free;
End; End;
End. End.