Skip to content

Commit

Permalink
feat: Added 'selected process/number of processes' tag at the bottom …
Browse files Browse the repository at this point in the history
…right.

Signed-off-by: Jan Willems <jw@elevenbits.com>
  • Loading branch information
jw committed Feb 29, 2024
1 parent b613133 commit 2dff9ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Binary file added docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crossterm::{
use log::info;
use procfs::process::Process;
use ratatui::layout::Constraint::Percentage;
use ratatui::widgets::block::Position;
use ratatui::widgets::{
Cell, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, Table, TableState,
};
Expand Down Expand Up @@ -191,7 +192,7 @@ fn ui(frame: &mut Frame, app: &mut App) {
.constraints([Percentage(100)])
.split(frame.size());

info!("Battery state is {}.", model::get_battery());
// info!("Battery state is {}.", model::get_battery());
let rows = model::create_rows(&app.processes);

let scrollbar = Scrollbar::new(ScrollbarOrientation::VerticalRight)
Expand Down Expand Up @@ -220,8 +221,16 @@ fn ui(frame: &mut Frame, app: &mut App) {
.height(1)
.style(Style::default().bold());

let processes = app.processes.len();
let process = format!("{}/{}", app.state.selected().unwrap() + 1, processes);

let block = Block::default()
.title(Title::from("brt").alignment(Alignment::Center))
.title(
Title::from(process)
.position(Position::Bottom)
.alignment(Alignment::Right),
)
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::White))
.border_type(BorderType::Rounded);
Expand Down
1 change: 1 addition & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ratatui::text::Line;
use ratatui::widgets::{Cell, Row};
use uzers::{get_user_by_uid, User};

#[allow(dead_code)]
pub fn get_battery() -> String {
let manager = battery::Manager::new().unwrap();
let battery = manager.batteries().unwrap().next().unwrap().unwrap();
Expand Down

0 comments on commit 2dff9ca

Please sign in to comment.