mirror of
https://github.com/uutils/procps.git
synced 2026-05-06 06:06:43 -04:00
top: tui impl irix info
This commit is contained in:
@@ -121,7 +121,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
{
|
||||
let header = Header::new(&tui_stat.read().unwrap());
|
||||
let proc_list = ProcList::new(&settings, &tui_stat.read().unwrap());
|
||||
tui_stat.write().unwrap().input_error = None;
|
||||
tui_stat.write().unwrap().input_message = None;
|
||||
*data.write().unwrap() = (header, proc_list);
|
||||
should_update.store(true, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ pub fn handle_input(
|
||||
{
|
||||
let mut stat = tui_stat.write().unwrap();
|
||||
stat.irix_mode = !stat.irix_mode;
|
||||
stat.input_message = Some(format!(
|
||||
" Irix mode {} ",
|
||||
if stat.irix_mode { "On" } else { "Off" }
|
||||
));
|
||||
}
|
||||
|
||||
data.write().unwrap().1 = ProcList::new(settings, &tui_stat.read().unwrap());
|
||||
@@ -312,7 +316,7 @@ fn handle_input_value(
|
||||
if input_value.is_err() {
|
||||
let mut stat = tui_stat.write().unwrap();
|
||||
stat.reset_input();
|
||||
stat.input_error = Some(" invalid number ".into());
|
||||
stat.input_message = Some(" invalid number ".into());
|
||||
should_update.store(true, Ordering::Relaxed);
|
||||
return;
|
||||
}
|
||||
@@ -332,7 +336,7 @@ fn handle_input_value(
|
||||
{
|
||||
let mut stat = tui_stat.write().unwrap();
|
||||
stat.reset_input();
|
||||
stat.input_error = Some(" invalid numa node ".into());
|
||||
stat.input_message = Some(" invalid numa node ".into());
|
||||
should_update.store(true, Ordering::Relaxed);
|
||||
return;
|
||||
}
|
||||
@@ -359,7 +363,7 @@ fn handle_input_value(
|
||||
Err(_) => {
|
||||
let mut stat = tui_stat.write().unwrap();
|
||||
stat.reset_input();
|
||||
stat.input_error = Some(" invalid user ".into());
|
||||
stat.input_message = Some(" invalid user ".into());
|
||||
should_update.store(true, Ordering::Relaxed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ impl<'a> Tui<'a> {
|
||||
|
||||
fn render_input(&self, area: Rect, buf: &mut Buffer) {
|
||||
let colorful = self.stat.colorful;
|
||||
if let Some(v) = self.stat.input_error.as_ref() {
|
||||
if let Some(v) = self.stat.input_message.as_ref() {
|
||||
let layout = Layout::new(
|
||||
Direction::Horizontal,
|
||||
[Constraint::Length(v.len() as u16), Constraint::Fill(1)],
|
||||
|
||||
@@ -11,7 +11,7 @@ pub(crate) struct TuiStat {
|
||||
pub input_mode: InputMode,
|
||||
pub input_label: String,
|
||||
pub input_value: String,
|
||||
pub input_error: Option<String>,
|
||||
pub input_message: Option<String>, // Info or error
|
||||
|
||||
pub show_load_avg: bool,
|
||||
pub cpu_graph_mode: CpuGraphMode,
|
||||
@@ -48,7 +48,7 @@ impl TuiStat {
|
||||
input_mode: InputMode::Command,
|
||||
input_label: String::new(),
|
||||
input_value: String::new(),
|
||||
input_error: None,
|
||||
input_message: None,
|
||||
|
||||
show_load_avg: true,
|
||||
cpu_graph_mode: CpuGraphMode::default(),
|
||||
@@ -77,7 +77,7 @@ impl TuiStat {
|
||||
self.input_mode = InputMode::Command;
|
||||
self.input_label.clear();
|
||||
self.input_value.clear();
|
||||
self.input_error = None;
|
||||
self.input_message = None;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user