From 63559385e7861658e8e9a907636519f18fe74c0e Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Fri, 5 Nov 2021 00:17:50 -0400 Subject: [PATCH 1/6] base lua tui window --- tui.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tui.lua diff --git a/tui.lua b/tui.lua new file mode 100644 index 0000000..f2b932f --- /dev/null +++ b/tui.lua @@ -0,0 +1,14 @@ +local ltui = require("ltui") +local application = ltui.application +local event = ltui.event +local rect = ltui.rect +local window = ltui.window +local demo = application() + +function demo:init() + application.init(self, "demo") + self:background_set("blue") + self:insert(window:new("window.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main window", true)) +end + +demo:run() From eea5ee0e3f8cef627492b8043462d67e800ad69c Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Fri, 5 Nov 2021 01:04:53 -0400 Subject: [PATCH 2/6] changed ui to a dialog --- tui.lua | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tui.lua b/tui.lua index f2b932f..7a80b6c 100644 --- a/tui.lua +++ b/tui.lua @@ -1,14 +1,47 @@ +-- requires local ltui = require("ltui") +local label = ltui.label +local button = ltui.button local application = ltui.application local event = ltui.event local rect = ltui.rect -local window = ltui.window -local demo = application() +local inputdialog = ltui.inputdialog +-- the demo application +local demo = application() + +-- init demo function demo:init() + + -- init name application.init(self, "demo") + + -- init background self:background_set("blue") - self:insert(window:new("window.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main window", true)) + + -- init input dialog + self:insert(self:dialog_input(), {centerx = true, centery = true}) end +-- input dialog +function demo:dialog_input() + local dialog_input = self._DIALOG_INPUT + if not dialog_input then + dialog_input = inputdialog:new("dialog.input", rect{0, 0, math.floor(self:width() / 2), math.floor(self:height() / 3)}) + dialog_input:text():text_set("please input text:") + dialog_input:button_add("no", "< No >", function (v) dialog_input:quit() end) + dialog_input:button_add("yes", "< Yes >", function (v) dialog_input:quit() end) + self._DIALOG_INPUT = dialog_input + end + return dialog_input +end + +-- on resize +function demo:on_resize() + self:dialog_input():bounds_set(rect{0, 0, math.floor(self:width() / 2), math.floor(self:height() / 3)}) + self:center(self:dialog_input(), {centerx = true, centery = true}) + application.on_resize(self) +end + +-- run demo demo:run() From dc49dbf65b6ec0c13166d7358055c8b76aa634ed Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Fri, 5 Nov 2021 01:05:18 -0400 Subject: [PATCH 3/6] changed ui to a dialog --- tui.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tui.lua b/tui.lua index 7a80b6c..e339656 100644 --- a/tui.lua +++ b/tui.lua @@ -1,3 +1,28 @@ +--!A cross-platform terminal ui library based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file inputdialog.lua +-- +-- require("tests/load") + -- requires local ltui = require("ltui") local label = ltui.label From 533eb5243e12c96d36e902dfb35b7e43470aadf3 Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Fri, 5 Nov 2021 17:08:47 -0400 Subject: [PATCH 4/6] not going to use LTUI --- tui.lua | 72 --------------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 tui.lua diff --git a/tui.lua b/tui.lua deleted file mode 100644 index e339656..0000000 --- a/tui.lua +++ /dev/null @@ -1,72 +0,0 @@ ---!A cross-platform terminal ui library based on Lua --- --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file inputdialog.lua --- --- require("tests/load") - --- requires -local ltui = require("ltui") -local label = ltui.label -local button = ltui.button -local application = ltui.application -local event = ltui.event -local rect = ltui.rect -local inputdialog = ltui.inputdialog - --- the demo application -local demo = application() - --- init demo -function demo:init() - - -- init name - application.init(self, "demo") - - -- init background - self:background_set("blue") - - -- init input dialog - self:insert(self:dialog_input(), {centerx = true, centery = true}) -end - --- input dialog -function demo:dialog_input() - local dialog_input = self._DIALOG_INPUT - if not dialog_input then - dialog_input = inputdialog:new("dialog.input", rect{0, 0, math.floor(self:width() / 2), math.floor(self:height() / 3)}) - dialog_input:text():text_set("please input text:") - dialog_input:button_add("no", "< No >", function (v) dialog_input:quit() end) - dialog_input:button_add("yes", "< Yes >", function (v) dialog_input:quit() end) - self._DIALOG_INPUT = dialog_input - end - return dialog_input -end - --- on resize -function demo:on_resize() - self:dialog_input():bounds_set(rect{0, 0, math.floor(self:width() / 2), math.floor(self:height() / 3)}) - self:center(self:dialog_input(), {centerx = true, centery = true}) - application.on_resize(self) -end - --- run demo -demo:run() From e90ab33dd8db262391c6c5a6ff209f494b89e476 Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Fri, 5 Nov 2021 17:54:18 -0400 Subject: [PATCH 5/6] tui bash prompt --- tui.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 tui.bash diff --git a/tui.bash b/tui.bash new file mode 100755 index 0000000..64b8b4a --- /dev/null +++ b/tui.bash @@ -0,0 +1,26 @@ +ARG_A=$(whiptail --inputbox "Please enter the value for \"a\":" 10 50 --title "Quadratic Calculator" 3>&1 1>&2 2>&3) + +exitstatus=$? +if [ $exitstatus = 0 ]; then +echo "a =" $ARG_A +else +echo "User canceled input." +fi + +ARG_B=$(whiptail --inputbox "Please enter the value for \"b\":" 10 50 --title "Quadratic Calculator" 3>&1 1>&2 2>&3) + +exitstatus=$? +if [ $exitstatus = 0 ]; then +echo "b =" $ARG_B +else +echo "User canceled input." +fi + +ARG_C=$(whiptail --inputbox "Please enter the value for \"C\":" 10 50 --title "Quadratic Calculator" 3>&1 1>&2 2>&3) + +exitstatus=$? +if [ $exitstatus = 0 ]; then +echo "c =" $ARG_C +else +echo "User canceled input." +fi From 352f3a9472ba1215b75b8ff2b4d5f2a7aecac440 Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Fri, 5 Nov 2021 18:01:13 -0400 Subject: [PATCH 6/6] tui completed --- tui.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tui.bash b/tui.bash index 64b8b4a..e71e96a 100755 --- a/tui.bash +++ b/tui.bash @@ -24,3 +24,5 @@ echo "c =" $ARG_C else echo "User canceled input." fi + +quadratic $ARG_A $ARG_B $ARG_C \ No newline at end of file