mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 01:26:04 -08:00
Write current path on explorer tabs
This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -175,6 +175,17 @@ dependencies = [
|
|||||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hostname"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"match_cfg",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
@@ -258,6 +269,12 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "match_cfg"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.3.4"
|
version = "2.3.4"
|
||||||
@@ -653,6 +670,7 @@ dependencies = [
|
|||||||
"crossterm",
|
"crossterm",
|
||||||
"ftp",
|
"ftp",
|
||||||
"getopts",
|
"getopts",
|
||||||
|
"hostname",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"regex",
|
"regex",
|
||||||
"rpassword",
|
"rpassword",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ bytesize = "1.0.1"
|
|||||||
textwrap = "0.12.1"
|
textwrap = "0.12.1"
|
||||||
regex = "1.4.2"
|
regex = "1.4.2"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
hostname = "0.3.1"
|
||||||
|
|
||||||
[target.'cfg(any(unix, macos, linux))'.dependencies]
|
[target.'cfg(any(unix, macos, linux))'.dependencies]
|
||||||
users = "0.11.0"
|
users = "0.11.0"
|
||||||
|
|||||||
@@ -19,10 +19,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
extern crate hostname;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Context, DialogYesNoOption, FileExplorerTab, FileTransferActivity, FsEntry, InputField,
|
Context, DialogYesNoOption, FileExplorerTab, FileTransferActivity, FsEntry, InputField,
|
||||||
InputMode, LogLevel, LogRecord, PopupType,
|
InputMode, LogLevel, LogRecord, PopupType,
|
||||||
};
|
};
|
||||||
|
use std::path::PathBuf;
|
||||||
use tui::{
|
use tui::{
|
||||||
layout::{Constraint, Corner, Direction, Layout, Rect},
|
layout::{Constraint, Corner, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
@@ -37,6 +40,7 @@ impl FileTransferActivity {
|
|||||||
/// Draw UI
|
/// Draw UI
|
||||||
pub(super) fn draw(&mut self) {
|
pub(super) fn draw(&mut self) {
|
||||||
let mut ctx: Context = self.context.take().unwrap();
|
let mut ctx: Context = self.context.take().unwrap();
|
||||||
|
let local_wrkdir: PathBuf = ctx.local.pwd();
|
||||||
let _ = ctx.terminal.draw(|f| {
|
let _ = ctx.terminal.draw(|f| {
|
||||||
// Prepare chunks
|
// Prepare chunks
|
||||||
let chunks = Layout::default()
|
let chunks = Layout::default()
|
||||||
@@ -66,12 +70,17 @@ impl FileTransferActivity {
|
|||||||
remote_state.select(Some(self.remote.index));
|
remote_state.select(Some(self.remote.index));
|
||||||
// Draw tabs
|
// Draw tabs
|
||||||
f.render_stateful_widget(
|
f.render_stateful_widget(
|
||||||
self.draw_local_explorer(),
|
self.draw_local_explorer(local_wrkdir),
|
||||||
tabs_chunks[0],
|
tabs_chunks[0],
|
||||||
&mut localhost_state,
|
&mut localhost_state,
|
||||||
);
|
);
|
||||||
|
// Get pwd
|
||||||
|
let remote_wrkdir: PathBuf = match self.client.pwd() {
|
||||||
|
Ok(p) => p,
|
||||||
|
Err(_) => PathBuf::from("/")
|
||||||
|
};
|
||||||
f.render_stateful_widget(
|
f.render_stateful_widget(
|
||||||
self.draw_remote_explorer(),
|
self.draw_remote_explorer(remote_wrkdir),
|
||||||
tabs_chunks[1],
|
tabs_chunks[1],
|
||||||
&mut remote_state,
|
&mut remote_state,
|
||||||
);
|
);
|
||||||
@@ -141,7 +150,11 @@ impl FileTransferActivity {
|
|||||||
/// ### draw_local_explorer
|
/// ### draw_local_explorer
|
||||||
///
|
///
|
||||||
/// Draw local explorer list
|
/// Draw local explorer list
|
||||||
pub(super) fn draw_local_explorer(&self) -> List {
|
pub(super) fn draw_local_explorer(&self, local_wrkdir: PathBuf) -> List {
|
||||||
|
let hostname: String = match hostname::get() {
|
||||||
|
Ok(h) => String::from(h.as_os_str().to_string_lossy()),
|
||||||
|
Err(_) => String::from("localhost"),
|
||||||
|
};
|
||||||
let files: Vec<ListItem> = self
|
let files: Vec<ListItem> = self
|
||||||
.local
|
.local
|
||||||
.files
|
.files
|
||||||
@@ -159,7 +172,7 @@ impl FileTransferActivity {
|
|||||||
},
|
},
|
||||||
_ => Style::default(),
|
_ => Style::default(),
|
||||||
})
|
})
|
||||||
.title("Localhost"),
|
.title(format!("{}:{} ", hostname, local_wrkdir.display())),
|
||||||
)
|
)
|
||||||
.start_corner(Corner::TopLeft)
|
.start_corner(Corner::TopLeft)
|
||||||
.highlight_style(
|
.highlight_style(
|
||||||
@@ -172,7 +185,7 @@ impl FileTransferActivity {
|
|||||||
/// ### draw_remote_explorer
|
/// ### draw_remote_explorer
|
||||||
///
|
///
|
||||||
/// Draw remote explorer list
|
/// Draw remote explorer list
|
||||||
pub(super) fn draw_remote_explorer(&self) -> List {
|
pub(super) fn draw_remote_explorer(&self, remote_wrkdir: PathBuf) -> List {
|
||||||
let files: Vec<ListItem> = self
|
let files: Vec<ListItem> = self
|
||||||
.remote
|
.remote
|
||||||
.files
|
.files
|
||||||
@@ -190,7 +203,7 @@ impl FileTransferActivity {
|
|||||||
},
|
},
|
||||||
_ => Style::default(),
|
_ => Style::default(),
|
||||||
})
|
})
|
||||||
.title(self.params.address.clone()),
|
.title(format!("{}:{} ", self.params.address, remote_wrkdir.display())),
|
||||||
)
|
)
|
||||||
.start_corner(Corner::TopLeft)
|
.start_corner(Corner::TopLeft)
|
||||||
.highlight_style(
|
.highlight_style(
|
||||||
|
|||||||
Reference in New Issue
Block a user