From 8c44cf02bbf4f5871534cc627aa71d756700dd21 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Thu, 23 May 2013 20:43:35 -0400 Subject: [PATCH] Now includes a "default" listbox search function (similar to the ANSI version) --- mdl/m_menubox.pas | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/mdl/m_menubox.pas b/mdl/m_menubox.pas index d52e624..76dc4ea 100644 --- a/mdl/m_menubox.pas +++ b/mdl/m_menubox.pas @@ -107,6 +107,27 @@ Implementation Uses m_Strings; +Procedure DefListBoxSearch (Var Owner: Pointer; Str: String); +Begin + If Str = '' Then + Str := strRep(BoxFrameType[TMenuList(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[TMenuList(Owner).Box.FrameType][7]; + End; + + TMenuList(Owner).Box.Console.WriteXY ( + TMenuList(Owner).SearchX, + TMenuList(Owner).SearchY, + TMenuList(Owner).SearchA, + Str); +End; + Constructor TMenuBox.Create (Var Screen: TOutput); Begin Inherited Create; @@ -240,7 +261,7 @@ Begin LastBarPos := 0; StatusProc := NIL; SearchProc := NIL; -// SearchProc := DefListBoxSearch; + SearchProc := DefListBoxSearch; SearchX := 0; SearchY := 0; SearchA := 0; @@ -439,6 +460,18 @@ Begin #00 : Begin Ch := InKey.ReadKey; + If Pos(Ch, HiChars) > 0 Then Begin + If SearchStr <> '' Then Begin + SearchStr := ''; + If Assigned(SearchProc) Then + SearchProc(Self, SearchStr); + End; + + ExitCode := Ch; + + Exit; + End; + Case Ch of #71 : If Picked > 1 Then Begin { home } Picked := 1; @@ -490,17 +523,6 @@ Begin Update; End; - Else - If Pos(Ch, HiChars) > 0 Then Begin - If SearchStr <> '' Then Begin - SearchStr := ''; - If Assigned(SearchProc) Then - SearchProc(Self, SearchStr); - End; - - ExitCode := Ch; - Exit; - End; End; End; Else