lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.28k stars 161 forks source link

Zoom with keyboard #117

Closed skrat closed 9 years ago

skrat commented 9 years ago

Zoom = scale = font size adjustment. That would be the common ^= for increment font size and ^- for decrement. This is super useful when you present a lot or you're changing monitors etc.

pik commented 9 years ago

I tried adding this but it doesn't reprint to fit - not sure how useful it is without that?

@lanoxx Is there an easy way to do the reprint? (Technically it might be good if text got re-fitted on fullscreen toggle as well).

lanoxx commented 9 years ago

I would imagin that libvte has some functions or signals to trigger a reprint. But I need to check the docs to be sure.

lanoxx commented 9 years ago

There is vte-terminal-set-size and vte-terminal-set-rewrap-on-resize: https://developer.gnome.org/vte/unstable/VteTerminal.html#vte-terminal-set-rewrap-on-resize

Maybe you need to call one of those?

lanoxx commented 9 years ago

There is vte-terminal-set-size and vte-terminal-set-rewrap-on-resize: https://developer.gnome.org/vte/unstable/VteTerminal.html#vte-terminal-set-rewrap-on-resize

Maybe you need to call one of those?

pik commented 9 years ago

I think that's already enabled by default. But as far as I understand that behaviour it's a wrap fixing behaviour (so if a line would overflow it will wrap it; it may also unwrap lines that weren't broken with \n) - but it won't for example expand a two column ls into six on fullscreen. (I installed gnome-terminal and the behaviour is the same on there as well).

You can try the shortcut keys for font size: https://github.com/pik/tilda/tree/font_size_shortcut If that seems like a useful behaviour i'll submit a PR.

lanoxx commented 9 years ago

I had a look at your code. For me it does not quite work as expected. I see a few issues:

Anyway, I think you should try a different approach, VTE already has code to increase and decrease the font-size, probably also for resetting, they are bound to CTRL+=, CTRL+- and probably CTRL+0 (for reset). The issue is that these commands don't reach the terminal widget because they are intercepted by the TildaWindow widget. I would try to change the code so that the hotkeys get passed on to the VTE widget (by returning GTK_EVENT_PROPAGATE in the callback).

If that works, then the font-size changing code in tilda can be removed all together.

skrat commented 9 years ago

@lanoxx lovely, passing the keys to VTE and letting it handle this, sounds very good. As of "certain font-sizes the text only expands the height and not the width", that's an issue (or a feature) of font rendering, I see this in other terminals and editors, I guess a freetype issue, not much we can do about it. But hey! Thanks for looking into this.

pik commented 9 years ago

@lanoxx Now that I think about it I'm not sure exactly why this wasn't catching the ctrl +/ ctrl - presses https://github.com/lanoxx/tilda/blob/master/src/tilda_terminal.c#L150. I'll have to look at Tilda's signal handling more closely. As a side-note passing the signal directly to VTE instead of handling in tilda_terminal will make it impossible rebind the the increase/decrease keys and font-increases will be limited to the selected tab (maybe this is desired?).

When decreasing the font size, somethings i see an artifact in the terminal: (arg: -1)

Thanks I missed that, the function should have been a gboolean instead of gint type to stop the signal from propagating.

lanoxx commented 9 years ago

@pik Changing to gboolean fixes the (arg: -1) issue. So the only problem is the odd scaling at certain font sizes. I just checked the code in gnome-terminal to see how its done there. It seems gnome-terminal handles font-scaling similar to your approach but it does not have the odd font-scaling issue. If we can fix the odd font scaling and if you add CTRL-0 do normalize the font-scale, then I am going to merge it.

You can find the relevant places in the gnome-terminal code here:

The thing is gnome-terminal uses scaling values instead of changing the font-size, but that requires VTE 2.91 and I would like to stay compatible with VTE 2.90, there is a separate issue about migrating to the 2.91 API (starting from VTE 0.38).

I have created a branch with a few fixes, I did not have time to clean it up but the scaling works now: https://github.com/lanoxx/tilda/commit/8a38dec871503cbc90bfcc53f33e7086a7469e36

It would be great if you can clean it up and add the keyboard accelerator for CTRL-0.

lanoxx commented 9 years ago

@pik Hey, I had some time just now. I have rebased the font-size branch and cleaned it up. Let me know what you think about it. It would be great if you can test it. If no issues come up, then I will merge it into the master branch.

I am still thinking if its necessary to configure the zoom hotkeys, its Ctrl 0, Ctrl - and Ctrl + on every other terminal (even in the browsers). Maybe it would be better to hard code those keys, what do you think?

lanoxx commented 9 years ago

Just for reference: 3a89638e12165fdbc843c2f222fa83621c3837b4

skrat commented 9 years ago

@lanoxx I have no problem with having those hard-coded. People don't usually re-map arrow keys, this is IMHO similar case.

pik commented 9 years ago

@lanoxx I have a slight problem that not writing the current font size to config means that when a new tab is created it's created with the config value (which might be a different size from the other tabs) - I think perhaps either a new tab should be created using the current scale - or the config value should be re-written on shortcut zoom (and the old value kept separately for the reset shortcut).

Maybe it would be better to hard code those keys, what do you think?

I find all of the default binds quite compatible - but some people have a lot of keybinds for e.g. their window managers (#110), so at least we should give them the option to unbind those keys.

lanoxx commented 9 years ago

@pik I have pushed another fix. Please take a look.

pik commented 9 years ago

@lanoxx Looks good! One thing I was wondering is whether you were planning to merge the toggle_transparency commit in with the font-size or rebase it out and handle that separately?

I'd like to do away with the redundant code i.e. https://github.com/pik/tilda/commit/edf812bd7e0b8f46382de78fe39d96e0cabb4e50 But the I did it like that the first time and had some error with including wizard.h in tilda_window. Now I am trying it and I can't produce any error so I don't know if that's good or not...

lanoxx commented 9 years ago

@pik I will rebase it before I merge it into master and handle that separately.

Lets continue this discussion in #103

lanoxx commented 9 years ago

Fixed by 116eb7e9b62ca1ec73114ebf78e5bc8dc178d575.

@pik I have set you as the author of that commit and added a sign-off tag to indicate that I have made some changes to your original commit. Thanks a lot for your help with this.

newsgrep commented 8 years ago

I'm sorry could one of you please tell me why CTRL+= is used to zoom in and not CTRL++ and how to rebind it? On my keyboard I have press shift+0 to create a '=' so I have to press CTRL+SHIFT+0 to zoom in and that is quite awkward and by missing the shift-key from time to time I execute a zoom-reset instead of the zoom in...

lucascollino commented 6 years ago

I second @newsgrep motion, ctrl + 0 resets, ctrl + - decreases, ctrl + + does nothing

psch-ci commented 5 years ago

thx for the info CTRL+= works .... but shouldn't i guess tilda is not honoring the exace local keyboard layout... (which is german in my case)