feat: resizable consoles (#65)
Some checks failed
Lockbud / lockbud (push) Has been cancelled
Rust / fmt (push) Has been cancelled
Rust / test (push) Has been cancelled
Rust / clippy (macos-latest) (push) Has been cancelled
Rust / clippy (ubuntu-latest) (push) Has been cancelled
Rust / check (macos-latest) (push) Has been cancelled
Rust / check (ubuntu-latest) (push) Has been cancelled
Rust / doc (push) Has been cancelled
Typo / typo (push) Has been cancelled

This commit is contained in:
Cyrix126 2025-01-01 15:02:07 +01:00 committed by GitHub
parent 550daa3681
commit 109c9a28b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 64 additions and 33 deletions

View file

@ -19,33 +19,47 @@ use std::sync::{Arc, Mutex};
use egui::{Label, TextEdit, TextStyle, TextWrapMode, Ui};
use crate::{DARK_GRAY, helper::Process, miscs::height_txt_before_button, regex::num_lines};
use crate::{
DARK_GRAY,
helper::{Process, ProcessName},
miscs::height_txt_before_button,
regex::num_lines,
};
pub fn console(ui: &mut Ui, text: &str) {
pub fn console(ui: &mut Ui, text: &str, console_height: &mut u32, process_name: ProcessName) {
let nb_lines = num_lines(text);
let height = ui.available_height() / 2.8;
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().wrap_mode = Some(TextWrapMode::Wrap);
ui.style_mut().override_text_style = Some(TextStyle::Small);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(ui.available_width())
.max_height(height)
.auto_shrink([false; 2])
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {
if let Some(line) = text.lines().nth(i) {
ui.label(line);
}
}
},
);
});
*console_height = egui::Resize::default()
.id_salt(process_name.to_string())
.default_height(*console_height as f32)
.min_width(ui.available_width())
.max_width(ui.available_width())
.show(ui, |ui| {
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
ui.style_mut().wrap_mode = Some(TextWrapMode::Wrap);
ui.style_mut().override_text_style = Some(TextStyle::Small);
egui::ScrollArea::vertical()
.stick_to_bottom(true)
.max_width(ui.available_width())
.max_height(ui.available_height())
.auto_shrink([false; 2])
// .show_viewport(ui, |ui, _| {
.show_rows(
ui,
ui.text_style_height(&TextStyle::Small),
nb_lines,
|ui, row_range| {
for i in row_range {
if let Some(line) = text.lines().nth(i) {
ui.label(line);
}
}
},
);
})
})
.response
.rect
.height() as u32;
}
// input args

View file

@ -29,8 +29,8 @@ use log::debug;
use crate::components::gupax::FileWindow;
use crate::disk::state::Node;
use crate::helper::Process;
use crate::helper::node::PubNodeApi;
use crate::helper::{Process, ProcessName};
use crate::{P2POOL_IN, P2POOL_LOG, P2POOL_OUT, SPACE};
impl Node {
@ -56,7 +56,7 @@ impl Node {
egui::ScrollArea::vertical().show(ui, |ui| {
let text = &api.lock().unwrap().output;
ui.group(|ui| {
console(ui, text);
console(ui, text, &mut self.console_height, ProcessName::Node);
if !self.simple {
ui.separator();
input_args_field(

View file

@ -56,7 +56,7 @@ impl P2pool {
egui::ScrollArea::vertical().show(ui, |ui| {
let text = &api_lock.output;
ui.group(|ui| {
console(ui, text);
console(ui, text, &mut self.console_height, ProcessName::P2pool);
if !self.simple {
ui.separator();
input_args_field(

View file

@ -23,8 +23,8 @@ use crate::app::panels::middle::common::state_edit_field::{
};
use crate::constants::*;
use crate::disk::state::Xmrig;
use crate::helper::Process;
use crate::helper::xrig::xmrig::PubXmrigApi;
use crate::helper::{Process, ProcessName};
use crate::miscs::height_txt_before_button;
use crate::regex::REGEXES;
use egui::{Checkbox, Ui, vec2};
@ -58,7 +58,7 @@ impl Xmrig {
egui::ScrollArea::vertical().show(ui, |ui| {
ui.group(|ui| {
let text = &api.lock().unwrap().output;
console(ui, text);
console(ui, text, &mut self.console_height, ProcessName::Xmrig);
if !self.simple {
ui.separator();
input_args_field(

View file

@ -24,8 +24,8 @@ use crate::app::panels::middle::common::console::{console, input_args_field, sta
use crate::app::panels::middle::common::header_tab::header_tab;
use crate::app::panels::middle::common::list_poolnode::list_poolnode;
use crate::disk::state::XmrigProxy;
use crate::helper::Process;
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::{Process, ProcessName};
use crate::miscs::height_txt_before_button;
use crate::regex::REGEXES;
use crate::{
@ -59,7 +59,7 @@ impl XmrigProxy {
egui::ScrollArea::vertical().show(ui, |ui| {
ui.group(|ui| {
let text = &api.lock().unwrap().output;
console(ui, text);
console(ui, text, &mut self.console_height, ProcessName::XmrigProxy);
//---------------------------------------------------------------------------------------------------- [Advanced] Console
if !self.simple {
ui.separator();

View file

@ -27,6 +27,7 @@ use crate::app::panels::middle::common::console::console;
use crate::app::panels::middle::common::header_tab::header_tab;
use crate::app::panels::middle::common::state_edit_field::StateTextEdit;
use crate::disk::state::{ManualDonationLevel, ManualDonationMetric, XvbMode};
use crate::helper::ProcessName;
use crate::helper::xrig::xmrig::PubXmrigApi;
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::PubXvbApi;
@ -83,7 +84,7 @@ impl crate::disk::state::Xvb {
debug!("XvB Tab | Rendering [Console]");
ui.group(|ui| {
let text = &api.lock().unwrap().output;
console(ui, text);
console(ui, text, &mut self.console_height, ProcessName::Xvb);
});
// input token
ui.add_space(SPACE);

View file

@ -301,6 +301,7 @@ pub struct P2pool {
pub zmq: String,
pub selected_node: SelectedPoolNode,
pub prefer_local_node: bool,
pub console_height: u32,
}
// compatible for P2Pool and Xmrig/Proxy
@ -328,6 +329,7 @@ pub struct Node {
pub dns_blocklist: bool,
pub disable_dns_checkpoint: bool,
pub path_db: String,
pub console_height: u32,
}
impl Default for Node {
@ -346,6 +348,7 @@ impl Default for Node {
dns_blocklist: true,
disable_dns_checkpoint: true,
path_db: String::new(),
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
}
}
}
@ -369,6 +372,7 @@ pub struct Xmrig {
pub port: String,
pub selected_pool: SelectedPoolNode,
pub token: String,
pub console_height: u32,
}
// present for future.
@ -391,6 +395,7 @@ pub struct XmrigProxy {
pub selected_pool: SelectedPoolNode,
pub token: String,
pub redirect_local_xmrig: bool,
pub console_height: u32,
}
impl Gupax {
@ -453,6 +458,7 @@ impl Default for XmrigProxy {
api_port: "18089".to_string(),
tls: false,
keepalive: false,
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
}
}
}
@ -469,6 +475,7 @@ pub struct Xvb {
pub manual_donation_metric: ManualDonationMetric,
pub p2pool_buffer: i8,
pub use_p2pool_sidechain_hr: bool,
pub console_height: u32,
}
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default, EnumCount, EnumIter)]
@ -621,6 +628,7 @@ impl Default for P2pool {
zmq_rig: "18083".to_string(),
},
prefer_local_node: true,
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
}
}
}
@ -665,6 +673,7 @@ impl Default for Xmrig {
.take(16)
.map(char::from)
.collect(),
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
}
}
}
@ -682,6 +691,7 @@ impl Default for Xvb {
manual_donation_metric: Default::default(),
p2pool_buffer: 25,
use_p2pool_sidechain_hr: false,
console_height: APP_DEFAULT_CONSOLE_HEIGHT,
}
}
}

View file

@ -84,6 +84,7 @@ mod test {
rpc = "18089"
zmq = "18083"
prefer_local_node = true
console_height = 360
[p2pool.selected_node]
index = 0
@ -109,6 +110,7 @@ mod test {
ip = "192.168.1.122"
port = "3333"
token = "testtoken"
console_height = 360
[xmrig.selected_pool]
@ -136,6 +138,7 @@ mod test {
p2pool_port = "18088"
token = "testtoken"
redirect_local_xmrig = true
console_height = 360
[xmrig_proxy.selected_pool]
index = 0
@ -157,6 +160,7 @@ mod test {
node = "Europe"
p2pool_buffer = 5
use_p2pool_sidechain_hr = false
console_height = 360
[node]
simple = false
@ -172,6 +176,7 @@ mod test {
dns_blocklist = true
disable_dns_checkpoint = true
path_db = ""
console_height = 360
[version]
gupax = "v1.3.0"

View file

@ -40,6 +40,7 @@ pub const APP_MAX_HEIGHT: f32 = 2160.0;
// Default, 1280x960
pub const APP_DEFAULT_WIDTH: f32 = 1280.0;
pub const APP_DEFAULT_HEIGHT: f32 = 960.0;
pub const APP_DEFAULT_CONSOLE_HEIGHT: u32 = 360;
// App resolution scaling
pub const APP_MIN_SCALE: f32 = 0.1;
pub const APP_MAX_SCALE: f32 = 2.0;