Commit Graph

11 Commits

Author SHA1 Message Date
Guido Cella e49404cba9 console: let type set the cursor position
This allows keybindings such as:

a script-message-to console type "seek :0 absolute" 6
% script-message-to console type "seek  absolute-percent" 6

The cursor position 0 isn't allowed because it has the weird effect of
filling the console with the text twice, leaving the cursor in the
middle.
Negative positions would put the cursor n characters before the end, and
positions greater than the text's length at the end. They seem to work
at first, but the console breaks when you move the cursor, so they
aren't allowed.
It seems that float values don't cause issues, but I'm using the
argument's floor anyway to be safe. Using >= 1 instead of > 0 ignores
values like 0.5.
2020-10-27 17:10:50 +00:00
wm4 c2ee7bce4c console: reduce memory usage in default mode
This used 1 MB due to building the complete command and property list
when starting the script. These are needed only for auto-completion, so
build them only on demand. Since building them is fast enough, rebuild
them every time.

The key bindings table is not that much, but saves some KBs. Oddly, the
code to build it uses less memory than the table at runtime (???), so
build it at runtime as well.

Add 2 tactic collectgarbage() calls as well. This frees unused heap when
it is known that the script is going to be completely inactive until
re-enabled by the user.
2020-04-10 13:36:10 +02:00
wm4 c48fd48f1e console: fix typo in previous commit
Now keypad enter actually works.
2020-02-07 14:05:04 +01:00
wm4 f659cfd6e3 console: manually map numeric keypad (KP*) bindings
While mpv normally uses the text a key produces (as opposed to physical
key mappings), this is different with the keypad. This is for the sake
of making it possible to distinguish between these keys and the normal
number keys on the left side of a full size keyboard.

There were complaints that the keypad doesn't interact with console.lua,
so manually map them. This ignores numlock (behaves as if it's always
on), and maps KP_DEC to "." (even though it's mapped to "," on some
keyboards). The /*-+ keys produce ASCII on mpv (at least with X11) as an
inexplicable inconsistency, so there are no mappings for these.

Fixes: #7431
2020-02-07 13:51:25 +01:00
der richter 3275cd04b7 cocoa-cb: add support for forcing the dedicated GPU for rendering
this deprecates the old cocoa backend only option and moves it to the
general macos ones. add support for the new option in the cocoa-cb
layer creation and use the new option in the olde cocoa backend.

Fixes #7272
2020-01-26 12:12:22 +01:00
wm4 8e9644761a console: add a basic help command
It's not really great. But I think it's good enough to save someone
who's lost. Most importantly, it should become obvious _what_ the
console expects (input commands), and how to exit it.

Would be nice if we could show some documentation, or give a link to
documentation, but that's out of scope and/or not easy.

I considered implementing the "help" command as builtin command in
command.c. On the other hand, this could not show console.lua specific
help, so I implemented it in console.lua. The ad-hoc command parsing
(that sort-of mirrors mpv input command syntax) for the "help" command
is probably the worst part of this.
2019-12-24 16:08:04 +01:00
wm4 1d2fcb9227 console: do not strip leading spaces
As suggested by TheAMM and avih.
2019-12-24 16:04:00 +01:00
wm4 3267bcd210 console: reduce border size
This looks better if the ASS canvas size is used to scale according to
HiDPI factor (instead of font size).
2019-12-22 12:52:36 +01:00
wm4 05cd4c9e08 console: use hidpi scale reporting
I decided to factor this into the user's scale option (instead of
somehow using it as default if the user has not specified it), because
it makes the option handling simpler, and won't break things like
per-screen DPI if the user only wants to scale the console font by a
factor.
2019-12-20 13:00:39 +01:00
wm4 09ea3a424f console: adjust position to OSC
See previous commit.
2019-12-18 09:04:15 +01:00
James Ross-Gowan b3b2cc44fa console.lua: add this script
Merged from mpv-repl git repo commit 5ea2bf64f9c239f0326b02. Some
changes were made on top of it:

- Tabs were converted to 4 spaces indentation (plus some manual
  indentation fixes in some places).
- All user-visible mentions of "repl" were renamed to "console".
- The README was converted to a manpage (with heavy changes, some
  additions taken from stats.rst; rossy converted the key bindings
  table to RST).
- The method to change the default key binding was changed.
- Change minor detail about "font" default value setting (not a
  functional change).
- Integrate into the player as builtin script, including an option to
  prevent loading it.

Above changes and commit message done by wm4.

Signed-off-by: wm4 <wm4@nowhere>
2019-12-08 02:46:44 +01:00