diff options
| author | ruki <[email protected]> | 2022-09-09 00:45:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-09 00:45:10 +0800 |
| commit | 230c9fbc5ef72f88409d789c8064f224cbc579a8 (patch) | |
| tree | 24a74f6c873644d60229e9939396c7535b3e8479 | |
| parent | 4a4fe52b63bda69a97c9edd084bea5400b8db069 (diff) | |
improve mconfig
| -rw-r--r-- | xmake/core/ui/mconfdialog.lua | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/xmake/core/ui/mconfdialog.lua b/xmake/core/ui/mconfdialog.lua index 00ed021e7..b71e39874 100644 --- a/xmake/core/ui/mconfdialog.lua +++ b/xmake/core/ui/mconfdialog.lua @@ -53,7 +53,10 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> or <Back> to go back, <?> for H self:menuconf():on_event(event.command {"cm_back"}) self:buttons():select(self:button("select")) end) - self:button_add("exit", "< Exit >", function (v, e) self:quit() end) + self:button_add("exit", "< Exit >", function (v, e) + self:show_exit([[Did you wish to save your new configuration? +(Pressing <Esc> to continue your configuration.)]]) + end) self:button_add("help", "< Help >", function (v, e) self:show_help() end) self:button_add("save", "< Save >", function (v, e) self:action_on(action.ac_on_save) end) self:buttons():select(self:button("select")) @@ -262,6 +265,23 @@ function mconfdialog:searchdialog() return self._SEARCHDIALOG end +-- get exit dialog +function mconfdialog:exitdialog() + if not self._EXITDIALOG then + local exitdialog = textdialog:new("mconfdialog.exit", rect{0, 0, math.min(60, self:width() - 8), math.min(7, self:height())}, "") + exitdialog:background_set(self:frame():background()) + exitdialog:frame():background_set("cyan") + exitdialog:button_add("Yes", "< Yes >", function (v) + self:action_on(action.ac_on_save) + end) + exitdialog:button_add("No", "< No >", function (v) self:quit() end) + exitdialog:option_set("scrollable", false) + exitdialog:button_select("Yes") + self._EXITDIALOG = exitdialog + end + return self._EXITDIALOG +end + -- search configs via the given text function mconfdialog:search(configs, text) local results = {} @@ -340,6 +360,17 @@ function mconfdialog:show_result(text) end end +-- show exit dialog +function mconfdialog:show_exit(text) + local dialog_exit = self:exitdialog() + dialog_exit:text():text_set(text) + if not self:view("mconfdialog.exit") then + self:insert(dialog_exit, {centerx = true, centery = true}) + else + self:select(dialog_exit) + end +end + -- on event function mconfdialog:on_event(e) |
