mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
windows cleanup
This commit is contained in:
parent
dca7f66c6f
commit
1fec1a5008
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -5229,6 +5229,7 @@ dependencies = [
|
|||||||
"async-std",
|
"async-std",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
|
"chrono",
|
||||||
"clap 4.4.4",
|
"clap 4.4.4",
|
||||||
"config",
|
"config",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
|
@ -2,7 +2,6 @@ use crate::command_processor::*;
|
|||||||
use crate::peers_table_view::*;
|
use crate::peers_table_view::*;
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::tools::*;
|
use crate::tools::*;
|
||||||
use async_tungstenite::tungstenite::http::header::STRICT_TRANSPORT_SECURITY;
|
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use cursive::align::*;
|
use cursive::align::*;
|
||||||
use cursive::event::*;
|
use cursive::event::*;
|
||||||
@ -15,12 +14,12 @@ use cursive::Cursive;
|
|||||||
use cursive::CursiveRunnable;
|
use cursive::CursiveRunnable;
|
||||||
use cursive_flexi_logger_view::{CursiveLogWriter, FlexiLoggerView};
|
use cursive_flexi_logger_view::{CursiveLogWriter, FlexiLoggerView};
|
||||||
// use cursive_multiplex::*;
|
// use cursive_multiplex::*;
|
||||||
|
use chrono::{Datelike, Timelike};
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
|
||||||
use chrono::{Datelike, Timelike};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
///
|
///
|
||||||
@ -52,8 +51,6 @@ impl<T> Dirty<T> {
|
|||||||
|
|
||||||
pub type UICallback = Box<dyn Fn(&mut Cursive) + Send>;
|
pub type UICallback = Box<dyn Fn(&mut Cursive) + Send>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static START_TIME: AtomicU64 = AtomicU64::new(0);
|
static START_TIME: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
||||||
struct UIState {
|
struct UIState {
|
||||||
@ -357,7 +354,7 @@ impl UI {
|
|||||||
|
|
||||||
cursive_flexi_logger_view::parse_lines_to_log(
|
cursive_flexi_logger_view::parse_lines_to_log(
|
||||||
ColorStyle::primary().into(),
|
ColorStyle::primary().into(),
|
||||||
format!("> {} {}", UI::cli_ts(Self::get_start_time()) , text),
|
format!("> {} {}", UI::cli_ts(Self::get_start_time()), text),
|
||||||
);
|
);
|
||||||
match Self::run_command(s, text) {
|
match Self::run_command(s, text) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
@ -365,7 +362,7 @@ impl UI {
|
|||||||
let color = *Self::inner_mut(s).log_colors.get(&Level::Error).unwrap();
|
let color = *Self::inner_mut(s).log_colors.get(&Level::Error).unwrap();
|
||||||
cursive_flexi_logger_view::parse_lines_to_log(
|
cursive_flexi_logger_view::parse_lines_to_log(
|
||||||
color.into(),
|
color.into(),
|
||||||
format!(" {} Error: {}", UI::cli_ts(Self::get_start_time()), e)
|
format!(" {} Error: {}", UI::cli_ts(Self::get_start_time()), e),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,6 +461,31 @@ impl UI {
|
|||||||
Self::command_processor(s).start_connection();
|
Self::command_processor(s).start_connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn copy_to_clipboard_osc52<S: AsRef<str>>(s: &mut Cursive, text: S) {
|
||||||
|
// OSC52 clipboard copy for terminals
|
||||||
|
if std::io::stdout()
|
||||||
|
.write_all(
|
||||||
|
format!(
|
||||||
|
"\x1B]52;c;{}\x07",
|
||||||
|
data_encoding::BASE64.encode(text.as_ref().as_bytes()),
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
|
)
|
||||||
|
.is_ok()
|
||||||
|
&& std::io::stdout().flush().is_ok()
|
||||||
|
{
|
||||||
|
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
|
||||||
|
cursive_flexi_logger_view::parse_lines_to_log(
|
||||||
|
color.into(),
|
||||||
|
format!(
|
||||||
|
">> {} Copied: {}",
|
||||||
|
UI::cli_ts(Self::get_start_time()),
|
||||||
|
text.as_ref()
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn copy_to_clipboard<S: AsRef<str>>(s: &mut Cursive, text: S) {
|
fn copy_to_clipboard<S: AsRef<str>>(s: &mut Cursive, text: S) {
|
||||||
if let Ok(mut clipboard) = arboard::Clipboard::new() {
|
if let Ok(mut clipboard) = arboard::Clipboard::new() {
|
||||||
// X11/Wayland/other system copy
|
// X11/Wayland/other system copy
|
||||||
@ -471,36 +493,24 @@ impl UI {
|
|||||||
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
|
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
|
||||||
cursive_flexi_logger_view::parse_lines_to_log(
|
cursive_flexi_logger_view::parse_lines_to_log(
|
||||||
color.into(),
|
color.into(),
|
||||||
format!(">> {} Copied: {}", UI::cli_ts(Self::get_start_time()), text.as_ref()),
|
format!(
|
||||||
|
">> {} Copied: {}",
|
||||||
|
UI::cli_ts(Self::get_start_time()),
|
||||||
|
text.as_ref()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let color = *Self::inner_mut(s).log_colors.get(&Level::Warn).unwrap();
|
let color = *Self::inner_mut(s).log_colors.get(&Level::Warn).unwrap();
|
||||||
cursive_flexi_logger_view::parse_lines_to_log(
|
cursive_flexi_logger_view::parse_lines_to_log(
|
||||||
color.into(),
|
color.into(),
|
||||||
format!(">> {} Could not copy to clipboard", UI::cli_ts(Self::get_start_time()))
|
format!(
|
||||||
|
">> {} Could not copy to clipboard",
|
||||||
|
UI::cli_ts(Self::get_start_time())
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// OSC52 clipboard copy for terminals
|
Self::copy_to_clipboard_osc52(s, text)
|
||||||
if std::io::stdout()
|
|
||||||
.write_all(
|
|
||||||
format!(
|
|
||||||
"\x1B]52;c;{}\x07",
|
|
||||||
data_encoding::BASE64.encode(text.as_ref().as_bytes()),
|
|
||||||
)
|
|
||||||
.as_bytes(),
|
|
||||||
)
|
|
||||||
.is_ok()
|
|
||||||
&& std::io::stdout().flush().is_ok()
|
|
||||||
{
|
|
||||||
if std::io::stdout().flush().is_ok() {
|
|
||||||
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
|
|
||||||
cursive_flexi_logger_view::parse_lines_to_log(
|
|
||||||
color.into(),
|
|
||||||
format!(">> {} Copied: {}", UI::cli_ts(Self::get_start_time()), text.as_ref()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,14 +798,11 @@ impl UI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Public functions
|
// Public functions
|
||||||
|
|
||||||
|
#[allow(clippy::format_in_format_args)]
|
||||||
pub fn cli_ts(ts: u64) -> String {
|
pub fn cli_ts(ts: u64) -> String {
|
||||||
//let ts = get_timestamp();
|
|
||||||
|
|
||||||
let now = chrono::DateTime::<chrono::Utc>::from(SystemTime::now());
|
let now = chrono::DateTime::<chrono::Utc>::from(SystemTime::now());
|
||||||
let date = chrono::DateTime::<chrono::Utc>::from(UNIX_EPOCH + Duration::from_micros(ts));
|
let date = chrono::DateTime::<chrono::Utc>::from(UNIX_EPOCH + Duration::from_micros(ts));
|
||||||
|
|
||||||
@ -806,17 +813,20 @@ impl UI {
|
|||||||
if show_year || show_month || show_date {
|
if show_year || show_month || show_date {
|
||||||
UI::set_start_time();
|
UI::set_start_time();
|
||||||
}
|
}
|
||||||
format!("{}{}",
|
format!(
|
||||||
|
"{}{}",
|
||||||
if show_year || show_month || show_date {
|
if show_year || show_month || show_date {
|
||||||
format!("Day changed: {:04}/{:02}/{:02} \n",now.year(), now.month(), now.day())
|
format!(
|
||||||
|
"Day changed: {:04}/{:02}/{:02} \n",
|
||||||
|
now.year(),
|
||||||
|
now.month(),
|
||||||
|
now.day()
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
},
|
},
|
||||||
format!("{:02}:{:02}:{:02}",
|
format!("{:02}:{:02}:{:02}", now.hour(), now.minute(), now.second())
|
||||||
now.hour(),
|
)
|
||||||
now.minute(),
|
|
||||||
now.second()
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_start_time() {
|
pub fn set_start_time() {
|
||||||
@ -985,7 +995,6 @@ impl UI {
|
|||||||
// pub fn run(&mut self) {
|
// pub fn run(&mut self) {
|
||||||
// self.siv.run();
|
// self.siv.run();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackSink = Box<dyn FnOnce(&mut Cursive) + 'static + Send>;
|
type CallbackSink = Box<dyn FnOnce(&mut Cursive) + 'static + Send>;
|
||||||
@ -1088,7 +1097,10 @@ impl UISender {
|
|||||||
{
|
{
|
||||||
let inner = self.inner.lock();
|
let inner = self.inner.lock();
|
||||||
let color = *inner.log_colors.get(&log_color).unwrap();
|
let color = *inner.log_colors.get(&log_color).unwrap();
|
||||||
cursive_flexi_logger_view::parse_lines_to_log(color.into(), format!("{}: {}", UI::cli_ts(UI::get_start_time()), event));
|
cursive_flexi_logger_view::parse_lines_to_log(
|
||||||
|
color.into(),
|
||||||
|
format!("{}: {}", UI::cli_ts(UI::get_start_time()), event),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let _ = self.cb_sink.send(Box::new(UI::update_cb));
|
let _ = self.cb_sink.send(Box::new(UI::update_cb));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ impl SockAddr {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(IpAddr::V4(Ipv4Addr::new(
|
Some(IpAddr::V4(Ipv4Addr::new(
|
||||||
((s_addr >> 0) & 255u32) as u8,
|
(s_addr & 255u32) as u8,
|
||||||
((s_addr >> 8) & 255u32) as u8,
|
((s_addr >> 8) & 255u32) as u8,
|
||||||
((s_addr >> 16) & 255u32) as u8,
|
((s_addr >> 16) & 255u32) as u8,
|
||||||
((s_addr >> 24) & 255u32) as u8,
|
((s_addr >> 24) & 255u32) as u8,
|
||||||
@ -81,7 +81,7 @@ impl SockAddr {
|
|||||||
if s6_addr[0] == 0xfe && s6_addr[1] == 0x80 {
|
if s6_addr[0] == 0xfe && s6_addr[1] == 0x80 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(IpAddr::V6(Ipv6Addr::from(s6_addr.clone())))
|
Some(IpAddr::V6(Ipv6Addr::from(*s6_addr)))
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,21 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
Corrosion
|
Corrosion
|
||||||
GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git
|
GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git
|
||||||
GIT_TAG origin/master # Optionally specify a version tag or branch here
|
GIT_TAG v0.4.4 # Optionally specify a version tag or branch here
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(Corrosion)
|
FetchContent_MakeAvailable(Corrosion)
|
||||||
|
|
||||||
corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/../../rust/Cargo.toml CRATES veilid-flutter)
|
execute_process(COMMAND git rev-parse --show-cdup
|
||||||
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE relative_path_to_repository_root)
|
||||||
|
string(STRIP ${relative_path_to_repository_root} relative_path_to_repository_root)
|
||||||
|
|
||||||
|
get_filename_component(repository_root
|
||||||
|
"${CMAKE_SOURCE_DIR}/${relative_path_to_repository_root}"
|
||||||
|
ABSOLUTE)
|
||||||
|
|
||||||
|
corrosion_import_crate(MANIFEST_PATH ${repository_root}/../veilid/Cargo.toml CRATES veilid-flutter)
|
||||||
|
|
||||||
# Flutter-specific
|
# Flutter-specific
|
||||||
|
|
||||||
|
@ -9,12 +9,21 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
Corrosion
|
Corrosion
|
||||||
GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git
|
GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git
|
||||||
GIT_TAG v0.2.1 # Optionally specify a version tag or branch here
|
GIT_TAG v0.4.4 # Optionally specify a version tag or branch here
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(Corrosion)
|
FetchContent_MakeAvailable(Corrosion)
|
||||||
|
|
||||||
corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/../../rust/Cargo.toml CRATES veilid-flutter FEATURES rt-tokio )
|
execute_process(COMMAND git rev-parse --show-cdup
|
||||||
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE relative_path_to_repository_root)
|
||||||
|
string(STRIP ${relative_path_to_repository_root} relative_path_to_repository_root)
|
||||||
|
|
||||||
|
get_filename_component(repository_root
|
||||||
|
"${CMAKE_SOURCE_DIR}/${relative_path_to_repository_root}"
|
||||||
|
ABSOLUTE)
|
||||||
|
|
||||||
|
corrosion_import_crate(MANIFEST_PATH ${repository_root}/../veilid/Cargo.toml CRATES veilid-flutter)
|
||||||
|
|
||||||
# Flutter-specific
|
# Flutter-specific
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user