Commit: 79c92b917683fc07442958596ad89664094b70c2
Parent: f835ed2f7f115e09492711d32a2dd5409fef12a9
Author: Ren Tatsumoto
Date: Sat, 19 Dec 2020 16:43:36 +0300
new action: sub-seek+pause
Diffstat:
2 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/README.md b/README.md
@@ -271,12 +271,14 @@ The user may change some of the key bindings, though this step is not necessary.
Default bindings:
```
-Ctrl+c script-binding mpvacious-copy-sub-to-clipboard
-Ctrl+e script-binding mpvacious-export-note
-Ctrl+h script-binding mpvacious-sub-rewind
-a script-binding mpvacious-menu-open
-H script-binding mpvacious-sub-seek-back
-L script-binding mpvacious-sub-seek-forward
+Ctrl+c script-binding mpvacious-copy-sub-to-clipboard
+Ctrl+e script-binding mpvacious-export-note
+Ctrl+h script-binding mpvacious-sub-rewind
+a script-binding mpvacious-menu-open
+H script-binding mpvacious-sub-seek-back
+L script-binding mpvacious-sub-seek-forward
+Alt+h script-binding mpvacious-sub-seek-back-pause
+Alt+l script-binding mpvacious-sub-seek-forward-pause
```
These additional bindings aren't enabled by default but can be accessed via the menu by pressing `a`.
@@ -294,6 +296,7 @@ Ctrl+u script-binding mpvacious-update-last-note
These bindings work everywhere, even if the menu (covered later) is closed.
* `Shift+h` and `Shift+l` - Seek to the previous or the next subtitle.
+* `Alt+h` and `Alt+l` - Seek to the previous or the next subtitle, and pause.
* `Ctrl+h` - Seek to the start of the currently visible subtitle. Use it if you missed something.
* `Ctrl+e` - Export a card with the currently visible subtitle line on the front.
Use this when your subs are perfectly timed and the target sentence doesn't span multiple subs.
diff --git a/subs2srs.lua b/subs2srs.lua
@@ -307,19 +307,6 @@ local function construct_note_fields(sub_text, snapshot_filename, audio_filename
}
end
-local function _(fn, param1)
- return function() pcall(fn, param1) end
-end
-
-local function sub_seek(direction)
- mp.commandv("sub_seek", direction == 'backward' and '-1' or '1')
- mp.commandv("seek", "0.015", "relative+exact")
-end
-
-local function sub_rewind()
- mp.commandv('seek', subs.get_current()['start'] + 0.015, 'absolute')
-end
-
local function minutes_ago(m)
return (os.time() - 60 * m) * 1000
end
@@ -445,6 +432,25 @@ do
end
------------------------------------------------------------
+-- seeking: sub seek, sub rewind
+
+local function _(params)
+ return function() return pcall(table.unpack(params)) end
+end
+
+local function sub_seek(direction, pause)
+ mp.commandv("sub_seek", direction == 'backward' and '-1' or '1')
+ mp.commandv("seek", "0.015", "relative+exact")
+ if pause then
+ mp.set_property("pause", "yes")
+ end
+end
+
+local function sub_rewind()
+ mp.commandv('seek', subs.get_current()['start'] + 0.015, 'absolute')
+end
+
+------------------------------------------------------------
-- platform specific
local function init_platform_windows()
@@ -1327,9 +1333,11 @@ do
mp.add_key_binding("a", "mpvacious-menu-open", menu.open) -- a for advanced
-- Vim-like seeking between subtitle lines
- mp.add_key_binding("H", "mpvacious-sub-seek-back", _(sub_seek, 'backward'))
- mp.add_key_binding("L", "mpvacious-sub-seek-forward", _(sub_seek, 'forward'))
- mp.add_key_binding("ctrl+h", "mpvacious-sub-rewind", _(sub_rewind))
+ mp.add_key_binding("H", "mpvacious-sub-seek-back", _ { sub_seek, 'backward' })
+ mp.add_key_binding("L", "mpvacious-sub-seek-forward", _ { sub_seek, 'forward' })
+ mp.add_key_binding("Alt+h", "mpvacious-sub-seek-back-pause", _ { sub_seek, 'backward', true })
+ mp.add_key_binding("Alt+l", "mpvacious-sub-seek-forward-pause", _ { sub_seek, 'forward', true })
+ mp.add_key_binding("ctrl+h", "mpvacious-sub-rewind", _ { sub_rewind })
-- Unset by default
mp.add_key_binding(nil, "mpvacious-set-starting-line", subs.set_starting_line)