mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Removed log width
This commit is contained in:
@@ -60,7 +60,6 @@ use tuirealm::View;
|
|||||||
// -- Storage keys
|
// -- Storage keys
|
||||||
|
|
||||||
const STORAGE_EXPLORER_WIDTH: &str = "FILETRANSFER_EXPLORER_WIDTH";
|
const STORAGE_EXPLORER_WIDTH: &str = "FILETRANSFER_EXPLORER_WIDTH";
|
||||||
const STORAGE_LOGBOX_WIDTH: &str = "LOGBOX_WIDTH";
|
|
||||||
|
|
||||||
// -- components
|
// -- components
|
||||||
|
|
||||||
|
|||||||
@@ -807,19 +807,9 @@ impl FileTransferActivity {
|
|||||||
pub(super) fn update_logbox(&mut self) -> Option<(String, Msg)> {
|
pub(super) fn update_logbox(&mut self) -> Option<(String, Msg)> {
|
||||||
match self.view.get_props(super::COMPONENT_LOG_BOX) {
|
match self.view.get_props(super::COMPONENT_LOG_BOX) {
|
||||||
Some(props) => {
|
Some(props) => {
|
||||||
// Get width
|
|
||||||
let width: usize = self
|
|
||||||
.context
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.store
|
|
||||||
.get_unsigned(super::STORAGE_LOGBOX_WIDTH)
|
|
||||||
.unwrap_or(256);
|
|
||||||
// Make log entries
|
// Make log entries
|
||||||
let mut table: TableBuilder = TableBuilder::default();
|
let mut table: TableBuilder = TableBuilder::default();
|
||||||
for (idx, record) in self.log_records.iter().enumerate() {
|
for (idx, record) in self.log_records.iter().enumerate() {
|
||||||
// Split rows by width NOTE: -37 'cause log prefix -3 cause of log line cursor
|
|
||||||
let record_rows = textwrap::wrap(record.msg.as_str(), (width as usize) - 40);
|
|
||||||
// Add row if not first row
|
// Add row if not first row
|
||||||
if idx > 0 {
|
if idx > 0 {
|
||||||
table.add_row();
|
table.add_row();
|
||||||
@@ -829,42 +819,29 @@ impl FileTransferActivity {
|
|||||||
LogLevel::Warn => Color::Yellow,
|
LogLevel::Warn => Color::Yellow,
|
||||||
LogLevel::Info => Color::Green,
|
LogLevel::Info => Color::Green,
|
||||||
};
|
};
|
||||||
for (idx, row) in record_rows.iter().enumerate() {
|
table
|
||||||
match idx {
|
.add_col(TextSpan::from(format!(
|
||||||
0 => {
|
"{}",
|
||||||
// First row
|
record.time.format("%Y-%m-%dT%H:%M:%S%Z")
|
||||||
table
|
)))
|
||||||
.add_col(TextSpan::from(format!(
|
.add_col(TextSpan::from(" ["))
|
||||||
"{}",
|
.add_col(
|
||||||
record.time.format("%Y-%m-%dT%H:%M:%S%Z")
|
TextSpanBuilder::new(
|
||||||
)))
|
format!(
|
||||||
.add_col(TextSpan::from(" ["))
|
"{:5}",
|
||||||
.add_col(
|
match record.level {
|
||||||
TextSpanBuilder::new(
|
LogLevel::Error => "ERROR",
|
||||||
format!(
|
LogLevel::Warn => "WARN",
|
||||||
"{:5}",
|
LogLevel::Info => "INFO",
|
||||||
match record.level {
|
}
|
||||||
LogLevel::Error => "ERROR",
|
)
|
||||||
LogLevel::Warn => "WARN",
|
.as_str(),
|
||||||
LogLevel::Info => "INFO",
|
)
|
||||||
}
|
.with_foreground(fg)
|
||||||
)
|
.build(),
|
||||||
.as_str(),
|
)
|
||||||
)
|
.add_col(TextSpan::from("]: "))
|
||||||
.with_foreground(fg)
|
.add_col(TextSpan::from(record.msg.as_ref()));
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
.add_col(TextSpan::from("]: "))
|
|
||||||
.add_col(TextSpan::from(row.as_ref()));
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
table.add_col(TextSpan::from(textwrap::indent(
|
|
||||||
row.as_ref(),
|
|
||||||
" ",
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let table = table.build();
|
let table = table.build();
|
||||||
let props = LogboxPropsBuilder::from(props)
|
let props = LogboxPropsBuilder::from(props)
|
||||||
|
|||||||
@@ -148,9 +148,6 @@ impl FileTransferActivity {
|
|||||||
if !store.isset(super::STORAGE_EXPLORER_WIDTH) {
|
if !store.isset(super::STORAGE_EXPLORER_WIDTH) {
|
||||||
store.set_unsigned(super::STORAGE_EXPLORER_WIDTH, tabs_chunks[0].width as usize);
|
store.set_unsigned(super::STORAGE_EXPLORER_WIDTH, tabs_chunks[0].width as usize);
|
||||||
}
|
}
|
||||||
if !store.isset(super::STORAGE_LOGBOX_WIDTH) {
|
|
||||||
store.set_unsigned(super::STORAGE_LOGBOX_WIDTH, chunks[1].width as usize);
|
|
||||||
}
|
|
||||||
// Draw explorers
|
// Draw explorers
|
||||||
// @! Local explorer (Find or default)
|
// @! Local explorer (Find or default)
|
||||||
match self.tab {
|
match self.tab {
|
||||||
|
|||||||
Reference in New Issue
Block a user