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
use std::ops::Deref;
use htmlescape::encode_minimal;
use gtk;
use gtk::prelude::*;
use crate::shell;
pub struct ErrorArea {
base: gtk::Box,
label: gtk::Label,
}
impl ErrorArea {
pub fn new() -> Self {
let base = gtk::Box::new(gtk::Orientation::Horizontal, 0);
let label = gtk::Label::new(None);
label.set_line_wrap(true);
let error_image = gtk::Image::new_from_icon_name(Some("dialog-error"), gtk::IconSize::Dialog);
base.pack_start(&error_image, false, true, 10);
base.pack_start(&label, true, true, 1);
ErrorArea { base, label }
}
pub fn show_nvim_init_error(&self, err: &str) {
error!("Can't initialize nvim: {}", err);
self.label.set_markup(&format!(
"<big>Can't initialize nvim:</big>\n\
<span foreground=\"red\"><i>{}</i></span>\n\n\
<big>Possible error reasons:</big>\n\
● Not supported nvim version (minimum supported version is <b>{}</b>)\n\
● Error in configuration file (init.vim or ginit.vim)",
encode_minimal(err),
shell::MINIMUM_SUPPORTED_NVIM_VERSION
));
self.base.show_all();
}
pub fn show_nvim_start_error(&self, err: &str, cmd: &str) {
error!("Can't start nvim: {}\nCommand line: {}", err, cmd);
self.label.set_markup(&format!(
"<big>Can't start nvim instance:</big>\n\
<i>{}</i>\n\
<span foreground=\"red\"><i>{}</i></span>\n\n\
<big>Possible error reasons:</big>\n\
● Not supported nvim version (minimum supported version is <b>{}</b>)\n\
● Error in configuration file (init.vim or ginit.vim)\n\
● Wrong nvim binary path \
(right path can be passed with <i>--nvim-bin-path=path_here</i>)",
encode_minimal(cmd),
encode_minimal(err),
shell::MINIMUM_SUPPORTED_NVIM_VERSION
));
self.base.show_all();
}
}
impl Deref for ErrorArea {
type Target = gtk::Box;
fn deref(&self) -> >k::Box {
&self.base
}
}