From 9556353c4fc33a148deb95bd208d7999df5605d7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 18 Aug 2024 13:51:42 +0300 Subject: [PATCH] exp: add progs strings tool --- Misc/qs_pak/scripts/expmode_progs.lua | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Misc/qs_pak/scripts/expmode_progs.lua b/Misc/qs_pak/scripts/expmode_progs.lua index 372b4d024..ec67e85aa 100644 --- a/Misc/qs_pak/scripts/expmode_progs.lua +++ b/Misc/qs_pak/scripts/expmode_progs.lua @@ -36,6 +36,7 @@ local fielddefinitions = progs.fielddefinitions local functions = progs.functions local globaldefinitions = progs.globaldefinitions local typename = progs.typename +local strings = progs.strings local addaction = expmode.addaction local resetsearch = expmode.resetsearch @@ -229,6 +230,65 @@ local function definitions_onhide(self) return true end +local function strings_searchcompare(entry, string) + return entry.value:lower():find(string, 1, true) +end + +local function strings_onupdate(self) + local title = self.title + local visible, opened = imBegin(title, true) + + if visible and opened then + local searchmodified = searchbar(self) + local entries = updatesearch(self, strings_searchcompare, searchmodified) + + if imBeginTable(title, 2, defaultTableFlags) then + imTableSetupScrollFreeze(0, 1) + imTableSetupColumn('Index', imTableColumnWidthFixed) + imTableSetupColumn('Value') + imTableHeadersRow() + + for _, entry in ipairs(entries) do + imTableNextRow() + imTableNextColumn() + imText(entry.index) + imTableNextColumn() + imText(entry.value) + end + + imEndTable() + end + end + + imEnd() + + return opened +end + +local function strings_onshow(self) + local entries = {} + + for i, value in ipairs(strings) do + local entry = + { + index = tostring(i), + value = value + } + insert(entries, entry) + end + + self.entries = entries + + updatesearch(self, strings_searchcompare, true) + return true +end + +local function strings_onhide(self) + resetsearch(self) + self.entries = nil + return true +end + addaction(function () if imBeginMenu('Progs') then if imMenuItem('Functions\u{85}') then @@ -259,6 +319,14 @@ addaction(function () oncreate, definitions_onshow, definitions_onhide) end + imSeparator() + + if imMenuItem('Strings\u{85}') then + window('Progs Strings', strings_onupdate, + function (self) self:setconstraints() end, + strings_onshow, strings_onhide) + end + imEndMenu() end end)