aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-02-12 12:59:48 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:47:49 +0530
commit6fc1a5bf921fa14209ce579348e4f1208ace81d7 (patch)
treeb0e7aed8a1bb8502e63446cceaa5aa4766dc7ef5
parentremove debug log file (diff)
downloadsl0ppij-6fc1a5bf921fa14209ce579348e4f1208ace81d7.tar.gz
sl0ppij-6fc1a5bf921fa14209ce579348e4f1208ace81d7.tar.xz
sl0ppij-6fc1a5bf921fa14209ce579348e4f1208ace81d7.zip
another try
-rw-r--r--abc.txt133
-rw-r--r--src/common/errors.rs2
-rw-r--r--src/common/mod.rs14
-rw-r--r--src/server/mod.rs36
4 files changed, 153 insertions, 32 deletions
diff --git a/abc.txt b/abc.txt
new file mode 100644
index 00000000..2bab52d8
--- /dev/null
+++ b/abc.txt
@@ -0,0 +1,133 @@
+warning: unused variable: `release`
+ --> build.rs:32:9
+ |
+32 | let release = if var("PROFILE").unwrap() == "release" {
+ | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_release`
+ |
+ = note: `#[warn(unused_variables)]` on by default
+
+warning: unused `std::result::Result` that must be used
+ --> build.rs:41:9
+ |
+41 | set_current_dir(&path);
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unused_must_use)]` on by default
+ = note: this `Result` may be an `Err` variant, which should be handled
+
+warning: unused `std::result::Result` that must be used
+ --> build.rs:61:5
+ |
+61 | set_current_dir(&starting_dir);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this `Result` may be an `Err` variant, which should be handled
+
+warning: 3 warnings emitted
+
+warning: unused import: `crate::utils::logging::debug_log_to_file`
+ --> src/common/wasm_vm.rs:8:5
+ |
+8 | use crate::utils::logging::debug_log_to_file;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unused_imports)]` on by default
+
+warning: unused import: `crate::layout::Layout`
+ --> src/server/mod.rs:8:5
+ |
+8 | use crate::layout::Layout;
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+warning: unused import: `ipc`
+ --> src/main.rs:11:35
+ |
+11 | command_is_executing, errors, ipc, os_input_output, pty_bus, screen, start, utils, wasm_vm,
+ | ^^^
+
+warning: unused variable: `ipc_thread`
+ --> src/common/mod.rs:191:9
+ |
+191 | let ipc_thread = start_server(
+ | ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_ipc_thread`
+ |
+ = note: `#[warn(unused_variables)]` on by default
+
+warning: unused variable: `err_ctx`
+ --> src/common/pty_bus.rs:294:72
+ |
+294 | pub fn spawn_terminals_for_layout(&mut self, layout_path: PathBuf, err_ctx: ErrorContext) {
+ | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_err_ctx`
+
+warning: unused variable: `err_ctx`
+ --> src/common/pty_bus.rs:314:46
+ |
+314 | pub fn close_pane(&mut self, id: PaneId, err_ctx: ErrorContext) {
+ | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_err_ctx`
+
+warning: unused variable: `maybe_layout`
+ --> src/server/mod.rs:42:9
+ |
+42 | let maybe_layout = opts.layout.or(default_layout);
+ | ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_maybe_layout`
+
+warning: variable does not need to be mutable
+ --> src/server/mod.rs:24:5
+ |
+24 | mut send_app_instructions: SenderWithContext<AppInstruction>,
+ | ----^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | help: remove this `mut`
+ |
+ = note: `#[warn(unused_mut)]` on by default
+
+warning: variable does not need to be mutable
+ --> src/server/mod.rs:28:9
+ |
+28 | let mut send_pty_instructions = SenderWithContext::new(
+ | ----^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | help: remove this `mut`
+
+warning: associated function is never used: `total_terminal_panes`
+ --> src/client/layout.rs:203:12
+ |
+203 | pub fn total_terminal_panes(&self) -> usize {
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(dead_code)]` on by default
+
+warning: function is never used: `start_client`
+ --> src/client/mod.rs:6:8
+ |
+6 | pub fn start_client() {}
+ | ^^^^^^^^^^^^
+
+warning: enum is never used: `ServerToClientMsg`
+ --> src/common/ipc.rs:41:10
+ |
+41 | pub enum ServerToClientMsg {
+ | ^^^^^^^^^^^^^^^^^
+
+warning: associated function is never used: `spawn_terminals_for_layout`
+ --> src/common/pty_bus.rs:294:12
+ |
+294 | pub fn spawn_terminals_for_layout(&mut self, layout_path: PathBuf, err_ctx: ErrorContext) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: unused `std::result::Result` that must be used
+ --> src/client/tab.rs:1904:9
+ |
+1904 | / debug_log_to_file(format!(
+1905 | | "set_pane_invisible_borders: {:?}",
+1906 | | invisible_borders
+1907 | | ));
+ | |___________^
+ |
+ = note: `#[warn(unused_must_use)]` on by default
+ = note: this `Result` may be an `Err` variant, which should be handled
+
+warning: 14 warnings emitted
+
+ Finished dev [unoptimized + debuginfo] target(s) in 0.17s
+ Running `target/debug/zellij`
diff --git a/src/common/errors.rs b/src/common/errors.rs
index 94682ebc..a9156ae6 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -64,7 +64,7 @@ pub fn handle_panic(
};
if thread == "main" {
- eprintln!("{}", backtrace);
+ println!("{}", backtrace);
process::exit(1);
} else {
send_app_instructions
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 4c8ab4c0..c737a788 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -141,11 +141,8 @@ impl IpcSenderWithContext {
}
pub fn send(&mut self, msg: ApiCommand) -> std::io::Result<()> {
- eprintln!("Ipcsender sending {:?}", msg);
let command = bincode::serialize(&(self.err_ctx, msg)).unwrap();
- UnixStream::connect(MOSAIC_IPC_PIPE)
- .unwrap()
- .write_all(&command)
+ self.sender.write_all(&command)
}
}
@@ -573,11 +570,10 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
os_input.unset_raw_mode(0);
let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1);
let error = format!("{}\n{}", goto_start_of_last_line, backtrace);
- //let _ = os_input
- // .get_stdout_writer()
- // .write(error.as_bytes())
- // .unwrap();
- eprintln!("{}", error);
+ let _ = os_input
+ .get_stdout_writer()
+ .write(error.as_bytes())
+ .unwrap();
std::process::exit(1);
}
AppInstruction::ToScreen(instruction) => {
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 0ba19568..1da079eb 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -90,15 +90,15 @@ pub fn start_server(
.unwrap();
}
PtyInstruction::NewTab => {
- //if let Some(layout) = maybe_layout.clone() {
- // pty_bus.spawn_terminals_for_layout(layout, err_ctx);
- //} else {
- let pid = pty_bus.spawn_terminal(None);
- pty_bus
- .send_server_instructions
- .send(ApiCommand::ToScreen(ScreenInstruction::NewTab(pid)))
- .unwrap();
- //}
+ if let Some(layout) = maybe_layout.clone() {
+ pty_bus.spawn_terminals_for_layout(layout, err_ctx);
+ } else {
+ let pid = pty_bus.spawn_terminal(None);
+ pty_bus
+ .send_server_instructions
+ .send(ApiCommand::ToScreen(ScreenInstruction::NewTab(pid)))
+ .unwrap();
+ }
}
PtyInstruction::ClosePane(id) => {
pty_bus.close_pane(id, err_ctx);
@@ -120,15 +120,14 @@ pub fn start_server(
.name("ipc_server".to_string())
.spawn({
move || {
- let mut threads = vec![];
for stream in listener.incoming() {
match stream {
Ok(stream) => {
let send_app_instructions = send_app_instructions.clone();
let send_pty_instructions = send_pty_instructions.clone();
- threads.push(thread::spawn(move || {
+ thread::spawn(move || {
handle_stream(send_pty_instructions, send_app_instructions, stream);
- }));
+ });
}
Err(err) => {
panic!("err {:?}", err);
@@ -137,9 +136,6 @@ pub fn start_server(
}
let _ = pty_thread.join();
- for t in threads {
- t.join();
- }
}
})
.unwrap()
@@ -150,21 +146,17 @@ fn handle_stream(
mut send_app_instructions: SenderWithContext<AppInstruction>,
mut stream: std::os::unix::net::UnixStream,
) {
- //let mut buffer = [0; 65535]; // TODO: more accurate
- let mut buffer = String::new();
+ let mut buffer = [0; 65535]; // TODO: more accurate
loop {
let bytes = stream
- .read_to_string(&mut buffer)
+ .read(&mut buffer)
.expect("failed to parse ipc message");
- //let astream = stream.try_clone().unwrap();
let (mut err_ctx, decoded): (ErrorContext, ApiCommand) =
- bincode::deserialize(buffer.as_bytes()).expect("failed to deserialize ipc message");
+ bincode::deserialize(&buffer[..bytes]).expect("failed to deserialize ipc message");
err_ctx.add_call(ContextType::IPCServer);
send_pty_instructions.update(err_ctx);
send_app_instructions.update(err_ctx);
- eprintln!("Server received {:?}", decoded);
-
match decoded {
ApiCommand::OpenFile(file_name) => {
let path = PathBuf::from(file_name);