summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-04-09 21:00:02 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-04-09 21:00:02 +0200
commit7636d3d5ce8423e6b5490e65553ef7f906f2608c (patch)
treef0c5d80e2100d4e56b6c5acfc8b3f4de5a45bcf7
parent8a9ee7a63f2b34f0d9d19c19598c75213114cf80 (diff)
TMP
-rw-r--r--Cargo.toml1
-rw-r--r--bin/imag-tui/Cargo.toml30
-rw-r--r--bin/imag-tui/src/bin.rs40
-rw-r--r--bin/imag-tui/src/lib.rs67
-rw-r--r--bin/imag-tui/src/ui.rs36
-rw-r--r--bin/imag-tui/src/views/dashboard.rs39
-rw-r--r--bin/imag-tui/src/views/mainview.rs47
-rw-r--r--bin/imag-tui/src/views/mod.rs23
-rw-r--r--bin/imag-tui/src/views/statusview.rs66
-rw-r--r--default.nix1
-rw-r--r--scripts/release.sh1
11 files changed, 351 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f50f39a1..ef090bb5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,6 +31,7 @@ members = [
"bin/domain/imag-timetrack",
"bin/domain/imag-todo",
"bin/domain/imag-wiki",
+ "bin/imag-tui",
"lib/core/libimagerror",
"lib/core/libimagrt",
"lib/core/libimagstore",
diff --git a/bin/imag-tui/Cargo.toml b/bin/imag-tui/Cargo.toml
new file mode 100644
index 00000000..1cb75548
--- /dev/null
+++ b/bin/imag-tui/Cargo.toml
@@ -0,0 +1,30 @@
+[package]
+name = "imag-tui"
+version = "0.10.0"
+authors = ["Matthias Beyer <mail@beyermatthias.de>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+cursive = "0.14"
+log = "0.4.6"
+clap = "2.33.0"
+anyhow = "1"
+resiter = "0.4.0"
+toml = "0.5.1"
+toml-query = "0.10"
+
+libimagentryutil = { version = "0.10.0", path = "../../lib/entry/libimagentryutil" }
+libimagerror = { version = "0.10.0", path = "../../lib/core/libimagerror" }
+libimagrt = { version = "0.10.0", path = "../../lib/core/libimagrt" }
+libimagstore = { version = "0.10.0", path = "../../lib/core/libimagstore" }
+libimagutil = { version = "0.10.0", path = "../../lib/etc/libimagutil" }
+
+[lib]
+name = "libimagtuifrontend"
+path = "src/lib.rs"
+
+[[bin]]
+name = "imag-tui"
+path = "src/bin.rs"
diff --git a/bin/imag-tui/src/bin.rs b/bin/imag-tui/src/bin.rs
new file mode 100644
index 00000000..a5129742
--- /dev/null
+++ b/bin/imag-tui/src/bin.rs
@@ -0,0 +1,40 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#![forbid(unsafe_code)]
+
+#![deny(
+ non_camel_case_types,
+ non_snake_case,
+ path_statements,
+ trivial_numeric_casts,
+ unstable_features,
+ unused_allocation,
+ unused_import_braces,
+ unused_imports,
+ unused_must_use,
+ unused_mut,
+ unused_qualifications,
+ while_true,
+)]
+
+#[macro_use] extern crate libimagrt;
+
+simple_imag_application_binary!(libimagtuifrontend, ImagTui);
+
diff --git a/bin/imag-tui/src/lib.rs b/bin/imag-tui/src/lib.rs
new file mode 100644
index 00000000..b0043ff2
--- /dev/null
+++ b/bin/imag-tui/src/lib.rs
@@ -0,0 +1,67 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#![forbid(unsafe_code)]
+
+extern crate clap;
+#[macro_use] extern crate log;
+extern crate toml;
+extern crate toml_query;
+#[macro_use] extern crate anyhow;
+extern crate resiter;
+extern crate cursive;
+
+extern crate libimagrt;
+extern crate libimagerror;
+extern crate libimagstore;
+extern crate libimagutil;
+extern crate libimagentryutil;
+
+use anyhow::Error;
+use anyhow::Result;
+use clap::App;
+
+use libimagrt::runtime::Runtime;
+use libimagrt::application::ImagApplication;
+
+mod ui;
+mod views;
+
+pub enum ImagTui {}
+impl ImagApplication for ImagTui {
+ fn run(rt: Runtime) -> Result<()> {
+ Ok(())
+ }
+
+ fn build_cli<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
+ ui::build_ui(app)
+ }
+
+ fn name() -> &'static str {
+ env!("CARGO_PKG_NAME")
+ }
+
+ fn description() -> &'static str {
+ "Bookmark collection tool"
+ }
+
+ fn version() -> &'static str {
+ env!("CARGO_PKG_VERSION")
+ }
+}
diff --git a/bin/imag-tui/src/ui.rs b/bin/imag-tui/src/ui.rs
new file mode 100644
index 00000000..d70da2b3
--- /dev/null
+++ b/bin/imag-tui/src/ui.rs
@@ -0,0 +1,36 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+use anyhow::Result;
+use clap::{ArgMatches, App};
+
+use libimagstore::storeid::StoreId;
+use libimagrt::runtime::IdPathProvider;
+
+pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
+ app
+}
+
+pub struct PathProvider;
+impl IdPathProvider for PathProvider {
+ fn get_ids(matches: &ArgMatches) -> Result<Option<Vec<StoreId>>> {
+ Ok(None)
+ }
+}
+
diff --git a/bin/imag-tui/src/views/dashboard.rs b/bin/imag-tui/src/views/dashboard.rs
new file mode 100644
index 00000000..1ccfc2a0
--- /dev/null
+++ b/bin/imag-tui/src/views/dashboard.rs
@@ -0,0 +1,39 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+use cursive::view::View;
+use cursive::Printer;
+
+use libimagrt::runtime::Runtime;
+
+pub struct Dashboard;
+
+impl Dashboard {
+ pub fn new() -> Self {
+ Dashboard
+ }
+}
+
+impl View for Dashboard {
+ fn draw(&self, printer: &Printer) {
+ // empty
+ }
+}
+
+
diff --git a/bin/imag-tui/src/views/mainview.rs b/bin/imag-tui/src/views/mainview.rs
new file mode 100644
index 00000000..2a563efa
--- /dev/null
+++ b/bin/imag-tui/src/views/mainview.rs
@@ -0,0 +1,47 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+use cursive::views::LinearLayout;
+use cursive::views::NamedView;
+use cursive::view::View;
+use cursive::Printer;
+
+use libimagrt::runtime::Runtime;
+
+use crate::views::dashboard::*;
+use crate::views::statusview::*;
+
+pub struct MainView<'a>(Runtime<'a>, LinearLayout);
+
+impl MainView {
+ fn new(rt: Runtime) -> NamedView<Self> {
+ NamedView::<MainView>::new(MainView(rt, {
+ LinearLayout::horizontal()
+ .child(NamedView::<Dashboard>::new("Dashboard", Dashboard::new()))
+ .child(NamedView::<StatusView>::new("NamedView", StatusView::new()))
+ }))
+ }
+}
+
+impl<'a> View for MainView<'a> {
+ fn draw(&self, printer: &Printer) {
+ self.1.draw(printer)
+ }
+}
+
diff --git a/bin/imag-tui/src/views/mod.rs b/bin/imag-tui/src/views/mod.rs
new file mode 100644
index 00000000..0073261d
--- /dev/null
+++ b/bin/imag-tui/src/views/mod.rs
@@ -0,0 +1,23 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+pub mod mainview;
+pub mod dashboard;
+pub mod statusview;
+
diff --git a/bin/imag-tui/src/views/statusview.rs b/bin/imag-tui/src/views/statusview.rs
new file mode 100644
index 00000000..72b29ce3
--- /dev/null
+++ b/bin/imag-tui/src/views/statusview.rs
@@ -0,0 +1,66 @@
+//
+// imag - the personal information management suite for the commandline
+// Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; version
+// 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+use cursive::views::LinearLayout;
+use cursive::views::EditView;
+use cursive::view::View;
+use cursive::Printer;
+
+use libimagrt::runtime::Runtime;
+
+pub struct StatusView(CurrentStatusView);
+
+impl StatusView {
+ pub fn new() -> Self {
+ StatusView(CurrentStatusView::Empty)
+ }
+}
+
+impl View for StatusView {
+ fn draw(&self, printer: &Printer) {
+ self.1.draw(printer)
+ }
+}
+
+
+enum CurrentStatusView {
+ Empty,
+
+ /// A list of buttons to click
+ Buttons(LinearLayout),
+
+ /// A Command-line (think vim ":")
+ ShellLine(EditView),
+
+ /// A Combination of a current shell line including a list of autocompletions
+ AutoCompleteList(LinearLayout),
+
+}
+
+impl View for CurrentStatusView {
+ fn draw(&self, printer: &Printer) {
+ match self {
+ CurrentStatusView::Empty => { },
+ CurrentStatusView::Buttons(ll) => ll.draw(printer),
+ CurrentStatusView::ShellLine(ev) => ev.draw(printer),
+ CurrentStatusView::AutoCompleteList(ll) => ll.draw(printer),
+ }
+ }
+}
+
diff --git a/default.nix b/default.nix
index d038df2a..c0147759 100644
--- a/default.nix
+++ b/default.nix
@@ -17,6 +17,7 @@ let
zlib
dbus
libtool
+ ncurses
];
in
diff --git a/scripts/release.sh b/scripts/release.sh
index 21ea10ae..f74c451a 100644
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -70,6 +70,7 @@ CRATES=(
./bin/core/imag-header
./bin/core/imag-create
./bin/core/imag
+ ./bin/imag-tui
)
for crate in ${CRATES[*]}; do