1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
//
// 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 std::sync::Arc;
use cursive::views::LinearLayout;
use cursive::views::Layer;
use cursive::views::EditView;
use cursive::views::ResizedView;
use cursive::views::TextView;
use cursive::view::View;
//use cursive::theme::ColorStyle;
use cursive::view::Boxable;
use cursive::Printer;
use cursive::view::SizeConstraint;
use libimagstore::store::Store;
pub struct StatusView(Arc<Store>, ResizedView<CurrentStatusView>);
impl StatusView {
pub fn new(store: Arc<Store>) -> Self {
StatusView(store, {
let mut rv = ResizedView::with_min_height(2, CurrentStatusView::new());
rv.set_height(SizeConstraint::Free);
rv
})
}
}
impl View for StatusView {
fn draw(&self, printer: &Printer) {
self.1.draw(printer)
}
}
enum CurrentStatusView {
Standard(LinearLayout),
/// 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 CurrentStatusView {
fn new() -> Self {
CurrentStatusView::Standard({
LinearLayout::vertical()
.child(TextView::new("[imag]").resized(SizeConstraint::AtMost(12), SizeConstraint::AtMost(4)))
.child(TextView::new("Dummy"))
})
}
}
impl View for CurrentStatusView {
fn draw(&self, printer: &Printer) {
match self {
CurrentStatusView::Standard(ll) => ll.draw(printer),
CurrentStatusView::Buttons(ll) => ll.draw(printer),
CurrentStatusView::ShellLine(ev) => ev.draw(printer),
CurrentStatusView::AutoCompleteList(ll) => ll.draw(printer),
}
}
}
|