Skip to content

Commit c9c9715

Browse files
ridleywinterspvolok
authored andcommitted
Add title configuration for the Processes pane
1 parent 36578f6 commit c9c9715

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,15 +882,15 @@ impl ClientHandle {
882882
&mut self,
883883
state: &mut State,
884884
layout: &AppLayout,
885-
_config: &Config,
885+
config: &Config,
886886
keymap: &Keymap,
887887
modal: &mut Option<Box<dyn Modal>>,
888888
rest: &mut [ClientHandle],
889889
) -> anyhow::Result<()> {
890890
self.terminal.draw(|f| {
891891
let mut cursor_style = self.cursor_style;
892892

893-
render_procs(layout.procs, f, state);
893+
render_procs(layout.procs, f, state, &config);
894894
render_term(layout.term, f, state, &mut cursor_style);
895895
render_keymap(layout.keymap, f, state, keymap);
896896
render_zoom_tip(layout.zoom_banner, f, keymap);

src/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use crate::{
1212
yaml_val::{value_to_string, Val},
1313
};
1414

15+
const DEFAULT_PROCESSES_TITLE: &'static str = "Processes";
16+
1517
pub struct ConfigContext {
1618
pub path: PathBuf,
1719
}
@@ -23,6 +25,7 @@ pub struct Config {
2325
pub mouse_scroll_speed: usize,
2426
pub scrollback_len: usize,
2527
pub proc_list_width: usize,
28+
pub title: String,
2629
}
2730

2831
impl Config {
@@ -62,13 +65,22 @@ impl Config {
6265
None
6366
};
6467

68+
let title = if let Some(title) = config.get(&Value::from("title")) {
69+
title.as_str()?.to_string()
70+
} else if let Some(title) = &settings.title {
71+
title.clone()
72+
} else {
73+
DEFAULT_PROCESSES_TITLE.to_string()
74+
};
75+
6576
let config = Config {
6677
procs,
6778
server,
6879
hide_keymap_window: settings.hide_keymap_window,
6980
mouse_scroll_speed: settings.mouse_scroll_speed,
7081
scrollback_len: settings.scrollback_len,
7182
proc_list_width: settings.proc_list_width,
83+
title,
7284
};
7385

7486
Ok(config)
@@ -82,6 +94,7 @@ impl Config {
8294
mouse_scroll_speed: settings.mouse_scroll_speed,
8395
scrollback_len: settings.scrollback_len,
8496
proc_list_width: settings.proc_list_width,
97+
title: DEFAULT_PROCESSES_TITLE.to_string(),
8598
}
8699
}
87100
}

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ use config_lua::load_lua_config;
3838
use ctl::run_ctl;
3939
use flexi_logger::{FileSpec, LoggerHandle};
4040
use host::{receiver::MsgReceiver, sender::MsgSender};
41+
use just::load_just_procs;
4142
use keymap::Keymap;
4243
use package_json::load_npm_procs;
43-
use just::load_just_procs;
4444
use proc::StopSignal;
4545
use serde_yaml::Value;
4646
use settings::Settings;
@@ -89,6 +89,7 @@ async fn run_app() -> anyhow::Result<()> {
8989
.arg(arg!(-c --config [PATH] "Config path [default: mprocs.yaml]"))
9090
.arg(arg!(-s --server [PATH] "Remote control server address. Example: 127.0.0.1:4050."))
9191
.arg(arg!(--ctl [YAML] "Send yaml/json encoded command to running mprocs"))
92+
.arg(arg!(--title [TITLE] "Title for the processes pane"))
9293
.arg(arg!(--names [NAMES] "Names for processes provided by cli arguments. Separated by comma."))
9394
.arg(arg!(--npm "Run scripts from package.json. Scripts are not started by default."))
9495
.arg(arg!(--just "Run recipes from justfile. Recipes are not started by default. Requires just to be installed."))
@@ -131,6 +132,10 @@ async fn run_app() -> anyhow::Result<()> {
131132
return run_ctl(ctl_arg, &config).await;
132133
}
133134

135+
if let Some(title) = matches.get_one::<String>("title") {
136+
config.title = title.to_string();
137+
}
138+
134139
if let Some(cmds) = matches.get_many::<String>("COMMANDS") {
135140
let names = matches
136141
.get_one::<String>("names")

src/settings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct Settings {
2121
pub mouse_scroll_speed: usize,
2222
pub scrollback_len: usize,
2323
pub proc_list_width: usize,
24+
pub title: Option<String>,
2425
}
2526

2627
impl Default for Settings {
@@ -33,6 +34,7 @@ impl Default for Settings {
3334
mouse_scroll_speed: 5,
3435
scrollback_len: 1000,
3536
proc_list_width: 30,
37+
title: None,
3638
};
3739
settings.add_defaults();
3840
settings

src/ui_procs.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ use tui::{
77
};
88

99
use crate::{
10+
config::Config,
1011
proc::handle::ProcHandle,
1112
state::{Scope, State},
1213
theme::Theme,
1314
};
1415

15-
pub fn render_procs(area: Rect, frame: &mut Frame, state: &mut State) {
16+
pub fn render_procs(
17+
area: Rect,
18+
frame: &mut Frame,
19+
state: &mut State,
20+
config: &Config,
21+
) {
1622
if area.width <= 2 {
1723
return;
1824
}
@@ -34,7 +40,10 @@ pub fn render_procs(area: Rect, frame: &mut Frame, state: &mut State) {
3440
.collect::<Vec<_>>();
3541

3642
let title = {
37-
let mut spans = vec![Span::styled("Processes", theme.pane_title(active))];
43+
let mut spans = vec![Span::styled(
44+
config.title.as_str(),
45+
theme.pane_title(active),
46+
)];
3847
if state.quitting {
3948
spans.push(Span::from(" "));
4049
spans.push(Span::styled(

0 commit comments

Comments
 (0)