Skip to content

Commit c675d8b

Browse files
committed
Add command to kill a window
1 parent 1ac2fde commit c675d8b

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/app/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ impl App {
514514
Hover => self.hover(),
515515
Insert => self.go_in_insert_mode(),
516516
Inspector => self.webview.emit(ShowInspector),
517+
KillWin => self.close_webview(),
517518
Mark(ref mark) => self.add_mark(mark),
518519
Normal => self.go_in_normal_mode(),
519520
Open(ref url) => self.open(url),

src/commands.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub enum AppCommand {
7272
Insert,
7373
#[help(text="Open the web inspector")]
7474
Inspector,
75+
#[help(text="Kill the webview without confirmation")]
76+
KillWin,
7577
#[completion(hidden)]
7678
Mark(String),
7779
#[completion(hidden)]

src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121

2222
/*
23+
* TODO: rename the quit command to close.
24+
* TODO: add a close-all command?
25+
*
2326
* TODO: automatically add new settings in the config files (kind of insertion sort, splitted by
2427
* the command?).
2528
*
@@ -48,8 +51,6 @@
4851
*
4952
* TODO: might not require the syntax with (relm) if we emit the signal normally.
5053
*
51-
* TODO: add a kill command to close a webview without try_close().
52-
*
5354
* TODO: remove dependencies like tokio.
5455
*
5556
* FIXME: windows opened by JavaScript cannot be claused: probably need to set the settings

tests/infinite_loop.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<body>
3+
<button id="block">Block</button>
4+
5+
<script>
6+
let button = document.querySelector("#block");
7+
button.addEventListener("click", function() {
8+
while(true) {
9+
}
10+
}, false);
11+
12+
window.onbeforeunload = function(){
13+
return 'Are you sure you want to leave?';
14+
};
15+
</script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)