Skip to content

Commit

Permalink
Strict handling of unauthorized cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
h1romas4 committed Aug 28, 2023
1 parent 587ff0e commit 9658a8d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"-it",
"--rm",
"ubuntu:22.04",
// "/usr/bin/bash"
"/opt/zellij/zellij",
"-l",
"plugin.kbl"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zellij-datetime"
version = "0.17.0"
version = "0.17.1"
authors = ["h1romas4 <[email protected]>"]
edition = "2021"

Expand Down
3 changes: 3 additions & 0 deletions plugin.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ layout {
enable_right_click true
}
}
pane size=1 borderless=true {
plugin location="file:./target/wasm32-wasi/debug/zellij-datetime.wasm"
}
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
Expand Down
17 changes: 11 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct State {
visible: bool,
line: Line,
config: Config,
permission_granted: bool,
}
register_plugin!(State);

Expand All @@ -44,10 +45,9 @@ impl ZellijPlugin for State {
EventType::Mouse,
]);
// request permission
self.permission_granted = false;
if self.config.get_enable_right_click() {
request_permission(&[
PermissionType::WriteToStdin,
]);
request_permission(&[PermissionType::WriteToStdin]);
} else {
set_selectable(false);
}
Expand All @@ -56,7 +56,10 @@ impl ZellijPlugin for State {
fn update(&mut self, event: Event) -> bool {
let mut should_render: bool = false;
match event {
Event::PermissionRequestResult(_result) => {
Event::PermissionRequestResult(result) => {
if result == PermissionStatus::Granted {
self.permission_granted = true;
}
// TODO:
// The default time zone disappears only at the first interactive query of permissions.
// Cause is being analyzed. Currently being addressed by re-setting.
Expand All @@ -65,7 +68,7 @@ impl ZellijPlugin for State {
self.reset_default_timezone();
// Use focus until permission authentication.
set_selectable(false);
},
}
Event::Visible(visible) => {
// TODO:
// If the Zellij session is detached, it is called with false,
Expand Down Expand Up @@ -97,7 +100,9 @@ impl ZellijPlugin for State {
}
Mouse::RightClick(_, _) => {
// write characters to the STDIN of the focused pane
self.write_now();
if self.config.get_enable_right_click() && self.permission_granted {
self.write_now();
}
}
Mouse::ScrollUp(_) => {
self.change_timezone_prev();
Expand Down

0 comments on commit 9658a8d

Please sign in to comment.