Skip to content

Commit 9eb7079

Browse files
committed
top: tui impl irix info
1 parent 82c1641 commit 9eb7079

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/uu/top/src/top.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
121121
{
122122
let header = Header::new(&tui_stat.read().unwrap());
123123
let proc_list = ProcList::new(&settings, &tui_stat.read().unwrap());
124-
tui_stat.write().unwrap().input_error = None;
124+
tui_stat.write().unwrap().input_message = None;
125125
*data.write().unwrap() = (header, proc_list);
126126
should_update.store(true, Ordering::Relaxed);
127127
}

src/uu/top/src/tui/input.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub fn handle_input(
7878
{
7979
let mut stat = tui_stat.write().unwrap();
8080
stat.irix_mode = !stat.irix_mode;
81+
stat.input_message = Some(format!(
82+
" Irix mode {} ",
83+
if stat.irix_mode { "On" } else { "Off" }
84+
));
8185
}
8286

8387
data.write().unwrap().1 = ProcList::new(settings, &tui_stat.read().unwrap());
@@ -312,7 +316,7 @@ fn handle_input_value(
312316
if input_value.is_err() {
313317
let mut stat = tui_stat.write().unwrap();
314318
stat.reset_input();
315-
stat.input_error = Some(" invalid number ".into());
319+
stat.input_message = Some(" invalid number ".into());
316320
should_update.store(true, Ordering::Relaxed);
317321
return;
318322
}
@@ -332,7 +336,7 @@ fn handle_input_value(
332336
{
333337
let mut stat = tui_stat.write().unwrap();
334338
stat.reset_input();
335-
stat.input_error = Some(" invalid numa node ".into());
339+
stat.input_message = Some(" invalid numa node ".into());
336340
should_update.store(true, Ordering::Relaxed);
337341
return;
338342
}
@@ -359,7 +363,7 @@ fn handle_input_value(
359363
Err(_) => {
360364
let mut stat = tui_stat.write().unwrap();
361365
stat.reset_input();
362-
stat.input_error = Some(" invalid user ".into());
366+
stat.input_message = Some(" invalid user ".into());
363367
should_update.store(true, Ordering::Relaxed);
364368
return;
365369
}

src/uu/top/src/tui/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'a> Tui<'a> {
354354

355355
fn render_input(&self, area: Rect, buf: &mut Buffer) {
356356
let colorful = self.stat.colorful;
357-
if let Some(v) = self.stat.input_error.as_ref() {
357+
if let Some(v) = self.stat.input_message.as_ref() {
358358
let layout = Layout::new(
359359
Direction::Horizontal,
360360
[Constraint::Length(v.len() as u16), Constraint::Fill(1)],

src/uu/top/src/tui/stat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) struct TuiStat {
1111
pub input_mode: InputMode,
1212
pub input_label: String,
1313
pub input_value: String,
14-
pub input_error: Option<String>,
14+
pub input_message: Option<String>, // Info or error
1515

1616
pub show_load_avg: bool,
1717
pub cpu_graph_mode: CpuGraphMode,
@@ -48,7 +48,7 @@ impl TuiStat {
4848
input_mode: InputMode::Command,
4949
input_label: String::new(),
5050
input_value: String::new(),
51-
input_error: None,
51+
input_message: None,
5252

5353
show_load_avg: true,
5454
cpu_graph_mode: CpuGraphMode::default(),
@@ -77,7 +77,7 @@ impl TuiStat {
7777
self.input_mode = InputMode::Command;
7878
self.input_label.clear();
7979
self.input_value.clear();
80-
self.input_error = None;
80+
self.input_message = None;
8181
}
8282
}
8383

0 commit comments

Comments
 (0)