mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Fixed logbox multi-lines not working properly; fixed exec command format
This commit is contained in:
@@ -449,7 +449,7 @@ impl FileTransferActivity {
|
|||||||
// Reload files
|
// Reload files
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
format!("\"{}\" output: \"{}\"", input, output).as_ref(),
|
format!("\"{}\": {}", input, output).as_ref(),
|
||||||
);
|
);
|
||||||
let wrkdir: PathBuf = self.local.wrkdir.clone();
|
let wrkdir: PathBuf = self.local.wrkdir.clone();
|
||||||
self.local_scan(wrkdir.as_path());
|
self.local_scan(wrkdir.as_path());
|
||||||
@@ -470,7 +470,7 @@ impl FileTransferActivity {
|
|||||||
// Reload files
|
// Reload files
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
format!("\"{}\" output: \"{}\"", input, output).as_ref(),
|
format!("\"{}\": {}", input, output).as_ref(),
|
||||||
);
|
);
|
||||||
self.reload_remote_dir();
|
self.reload_remote_dir();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -827,8 +827,9 @@ impl FileTransferActivity {
|
|||||||
// 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() {
|
||||||
let record_rows = textwrap::wrap(record.msg.as_str(), (width as usize) - 38); // -35 'cause log prefix -3 cause of log line cursor
|
// Split rows by width NOTE: -37 'cause log prefix -3 cause of log line cursor
|
||||||
// Add row if not first row
|
let record_rows = textwrap::wrap(record.msg.as_str(), (width as usize) - 40);
|
||||||
|
// Add row if not first row
|
||||||
if idx > 0 {
|
if idx > 0 {
|
||||||
table.add_row();
|
table.add_row();
|
||||||
}
|
}
|
||||||
@@ -868,7 +869,7 @@ impl FileTransferActivity {
|
|||||||
_ => {
|
_ => {
|
||||||
table.add_col(TextSpan::from(textwrap::indent(
|
table.add_col(TextSpan::from(textwrap::indent(
|
||||||
row.as_ref(),
|
row.as_ref(),
|
||||||
" ",
|
" ",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
use super::{Canvas, Component, InputEvent, Msg, Payload, Props, PropsBuilder};
|
use super::{Canvas, Component, InputEvent, Msg, Payload, Props, PropsBuilder};
|
||||||
// ext
|
// ext
|
||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
|
use std::collections::VecDeque;
|
||||||
use tui::{
|
use tui::{
|
||||||
layout::{Corner, Rect},
|
layout::{Corner, Rect},
|
||||||
style::Style,
|
style::Style,
|
||||||
@@ -145,7 +146,7 @@ impl Component for LogBox {
|
|||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, row)| {
|
.map(|(idx, row)| {
|
||||||
let mut columns: Vec<Span> = row
|
let mut columns: VecDeque<Span> = row
|
||||||
.iter()
|
.iter()
|
||||||
.map(|col| {
|
.map(|col| {
|
||||||
Span::styled(
|
Span::styled(
|
||||||
@@ -157,9 +158,10 @@ impl Component for LogBox {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let mut row: Vec<Span> = Vec::with_capacity(columns.len() + 1);
|
// Let's convert column spans into Spans rows NOTE: -4 because first line is always made by 5 columns; but there's always 1
|
||||||
// Push green cursor if selected line
|
let mut rows: Vec<Spans> = Vec::with_capacity(columns.len() - 4);
|
||||||
row.push(Span::styled(
|
// Get first row
|
||||||
|
let mut first_row: Vec<Span> = vec![Span::styled(
|
||||||
match self.states.list_index == idx {
|
match self.states.list_index == idx {
|
||||||
true => "> ",
|
true => "> ",
|
||||||
false => " ",
|
false => " ",
|
||||||
@@ -167,9 +169,21 @@ impl Component for LogBox {
|
|||||||
Style::default()
|
Style::default()
|
||||||
.fg(self.props.foreground)
|
.fg(self.props.foreground)
|
||||||
.bg(self.props.background),
|
.bg(self.props.background),
|
||||||
));
|
)];
|
||||||
row.append(&mut columns);
|
for _ in 0..5 {
|
||||||
ListItem::new(Spans::from(row))
|
if let Some(col) = columns.pop_front() {
|
||||||
|
first_row.push(col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows.push(Spans::from(first_row));
|
||||||
|
// Fill remaining rows
|
||||||
|
let cycles: usize = columns.len();
|
||||||
|
for _ in 0..cycles {
|
||||||
|
if let Some(col) = columns.pop_front() {
|
||||||
|
rows.push(Spans::from(vec![col]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListItem::new(rows)
|
||||||
})
|
})
|
||||||
.collect(), // Make List item from TextSpan
|
.collect(), // Make List item from TextSpan
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user