rkd77 / elinks

Fork of elinks
Other
349 stars 38 forks source link

exmode command 'set' does not seem to work #196

Closed smemsh closed 1 year ago

smemsh commented 1 year ago

meson compile, latest master with exmode support:

:set ui.show_title_bar = 0<enter>

accepts exmode input without error, but nothing happens on <enter>. tried refresh, etc no change. is :set supposed to work? :quit seems to work. :bind seems to work.

I also tried elinks -eval 'set ui.show_title_bar = 0 which only works with -no-connect, so I cannot use it to change values in session master.

rkd77 commented 1 year ago

Thanks for the report. It seems it did not work before.

smemsh commented 1 year ago

That works, thanks. Now if only this worked:

bind "main" "z" = "set ui.show_title_bar = 1"

but it seems that cannot be done. Is there a way to bind exmode/config statement to key?

rkd77 commented 1 year ago

Not yet. I've got an idea: config string options macro.0 to macro.9. Eg. set macro.0 = "set ui.show_title_bar = 0" set macro.1 = "set ui.show_title_bar = 1"

and actions: macro-0 macro-1 and so on.

and finally bind "main" "z" = "macro-0" bind "main" "Z" = "macro-1"

In code macro-0 will eval macro.0.

It can be done with minimal changes in code. Some problems can occur with double quotes in double quotes, but it can be addressed later. If there is no objections, I'll implement it this week.

rkd77 commented 1 year ago

Maybe too soon, but committed. Try it, please.

smemsh commented 1 year ago

is this the right syntax?

set macro.0 = "set ui.show_title_bar = 0"
set macro.1 = "set ui.show_title_bar = 1"
bind "main" "z" = "macro-0"
bind "main" "Z" = "macro-1"

set macro.2 = "set ui.show_status_bar = 0"
set macro.3 = "set ui.show_status_bar = 1"
bind "main" "s" = "macro-2"
bind "main" "S" = "macro-3"

set macro.4 = "set ui.date_format = \"%b %e %H:%M\""
set macro.5 = "set ui.date_format = \"%Y%m%d%H%M%S\""
bind "main" "d" = "macro-4"
bind "main" "D" = "macro-5"

none of them seem to change status or title bar (I'll move to dates once those work...) however they are seen in keybind manager (the mapping to macro is shown, but macro definition is not seen anywhere in options or keybinds, at least using search function, maybe it doesn't show up though). nothing happens when any of the keys are pressed. there are no parse errors on start.

rkd77 commented 1 year ago

Macros are visible in options manager as a separate category. ui.date_format is shown for example in cookies dialog. ui.clock.format is for clock. When ui.leds.enable is 0, changes require pressing addional key,

smemsh commented 1 year ago

I see now, the page needs redraw action for new setting to take effect. This means it is not equivalent to manual entry, as redraw is not required to affect change upon manual entry at exmode prompt. A compound statement terminator character could solve this, or allowing multiple values, to be evaluated in sequence, such as:

bind "main" "z" = "macro-0" "redraw"
rkd77 commented 1 year ago

If did not make mistake, semicolon is delimiter for commands in macros.

smemsh commented 1 year ago

awesome, can we add this to allow spaces after semi?

--- a/src/dialogs/exmode.c
+++ b/src/dialogs/exmode.c
@@ -132,6 +132,7 @@ try_exmode_exec(struct session *ses, const char *val)
        while (1) {
                char *command, *args;

+               while (*next && isspace((unsigned char)(*next))) next++;
                command = args = next;

                while (*command == ':') command++;
rkd77 commented 1 year ago

@smemsh , added. Thanks.

smemsh commented 1 year ago

everything works great, thank you!