Skip to content

Commit

Permalink
search box searches for partial matches instead of full match
Browse files Browse the repository at this point in the history
eg. shotgun shows everything with shotgun in the var name, instead of nothing since there is no variable named exactly shotgun but many that have shotgun in the name
  • Loading branch information
nochinator authored Jul 7, 2024
1 parent 8a91b12 commit 369aceb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions config/ui/vars.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ newui "vars" $SURFACE_FOREGROUND [
uiallowinput 1

local numvars scurflag scurvar searchstr
searchstr = (concatword $ui_vars_searchstr (? (|| (>= (strstr $ui_vars_searchstr "*") 0) (>= (strstr $ui_vars_searchstr "?") 0)) "" "*"))
numvars = (getvarinfo -1 $ui_vars_types $ui_vars_notypes $ui_vars_flags $ui_vars_noflags $ui_vars_searchstr 3)
// Remove the restrictive `?` and `*` checks for flexible matching
searchstr = (concatword $ui_vars_searchstr "*") // Using `*` wildcard for broader match

// Perform a flexible search using the updated `searchstr`
numvars = (getvarinfo -1 $ui_vars_types $ui_vars_notypes $ui_vars_flags $ui_vars_noflags $searchstr 3)

if (>= $ui_vars_num $numvars) [ ui_vars_init ]

Expand All @@ -205,7 +208,8 @@ newui "vars" $SURFACE_FOREGROUND [
uistyle lefttop
uivlist $ui_padbutton [
uistyle lefttop
uiinput ui_vars_searchstr 32 [ui_vars_num = -1] 1 0 "[click here to enter wildcard search text]" 0 [] [uialtrelease [ui_vars_searchstr = ""]]
// Changed the search function to use `ui_vars_searchstr`
uiinput ui_vars_searchstr 32 [ui_vars_num = -1; ui_vars_page = 0] 1 0 "[click here to enter search text]" 0 [] [uialtrelease [ui_vars_searchstr = ""]]
uihlist 0 [
uistyle clampx
uistyle leftmiddle
Expand Down Expand Up @@ -281,7 +285,7 @@ newui "vars" $SURFACE_FOREGROUND [
uihlist 0 [
uistyle clampx
uialign -1
ui_vars_curname = (getvarinfo $n $ui_vars_types $ui_vars_notypes $ui_vars_flags $ui_vars_noflags $ui_vars_searchstr 3)
ui_vars_curname = (getvarinfo $n $ui_vars_types $ui_vars_notypes $ui_vars_flags $ui_vars_noflags $searchstr 3)
uiradio $ui_vars_curname (= $ui_vars_num $n) $ui_radiosize [ui_vars_num = @n]
]
]
Expand Down Expand Up @@ -316,7 +320,7 @@ newui "vars" $SURFACE_FOREGROUND [
uistyle lefttop
uihlist 0 [uispace 0.3]
if (&& (>= $ui_vars_num 0) (< $ui_vars_num $numvars) (> $numvars 0)) [
scurvar = (getvarinfo $ui_vars_num $ui_vars_types $ui_vars_notypes $ui_vars_flags $ui_vars_noflags $ui_vars_searchstr)
scurvar = (getvarinfo $ui_vars_num $ui_vars_types $ui_vars_notypes $ui_vars_flags $ui_vars_noflags $searchstr)
uivlist $ui_padbutton [
uistyle lefttop
ui_vars_display $scurvar
Expand Down

0 comments on commit 369aceb

Please sign in to comment.