Allow platform-specific keybinding overrides. At the moment only for OS X where the keybindings can be set inside keybindings_osx.conf. Similar config files can be added for other platforms if needed in the future.
The only change is the new init_platform_kb() function which is called inside keybindings_init() (had to move it down a bit in the source code to avoid forward declarations but there's no other change in this function). You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1395
-- Commit Summary --
* Add support for platform-specific keybindings
-- File Changes --
M data/Makefile.am (1) A data/keybindings_osx.conf (1) M src/keybindings.c (44)
-- Patch Links --
https://github.com/geany/geany/pull/1395.patch https://github.com/geany/geany/pull/1395.diff
Looks ok to me, and definitely better than "having half the defaults `#ifdef`ed" as @b4n put it.
I completely disagree with platform-sepcific keybindings. As a user that uses Geany mostly on Linux, and occasionally on Windows, I would truly hate if I suddenly had to remember that keybindings differ.
I goes along the same lines different menu items. I still absolutely hate that Firefox on Windows has the preferences item in a different location than on Linux.
@kugel- this is in response to #1324 where its pointed out that some keys simply don't exist on some platforms, so the default bindings cannot work.
Unfortunately platforms ARE different and the common key sequences on different platforms ARE different. Yes it will upset your muscle memory, but there are more users confined to one platform than there are users like you straddling multiple platforms.
User confined to a platform would benefit from Geany using more platform specific bindings, and in the #1324 case will benefit from having a default binding at all.
Some of Scintilla's hardcoded keybindings are already different per platform.
As a MacOS user during the day I hate changed keybindings too. But as we have seen last year some of the keybiindings working fine on e.g. Linux/Xfce are just already in use by some system stuff on MacOS and of course they got different keys.
As it stands this requires any tester to define new keys.
@frlan, since OSX is the only platform where its proposed to use different keybindings and you are a day-to-day user, can you test this and in the process develop a set of OSX specific default keybindings?
I think Frank doesn't build Geany by himself but uses my builds which don't contain this patch yet. @frlan let me know if you want me to prepare a build for you which contains this patch. That said for providing the keybindings you actually don't need the patch, just copy/paste here the keybindings from your `.config/geany/keybindings.conf` that you think should be overridden for the platform.
Now I could prepare the custom keybindings by myself too but it requires some a bit boring work to check which of them are incompatible with OS X and possibly also checking some other editors to make the new ones platform-friendly so it's something that isn't radically different from what others do. I actually use only the basic keybindings and never ran into a problem with them so I'm not so motivated myself.
Should merge this if it does as advertised (cannot test ATM)
@codebrainz well, it needs to be tested in a non-OSX platform before merge, but the OSX part I would trust to techee as we have no other OSX testers
Well, nobody has written the OS X specific keybinding overrides yet so the patch won't do anything useful. Let's just wait until someone is motivated enough to create OS X specific keybindings and merge it then.
b4n requested changes on this pull request.
@@ -782,6 +768,36 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}
+static void init_platform_kb(void) +{ +#ifdef __APPLE__ + gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
why loading a platform-named file instead of simply `keybindings.conf`, and install a different one (or none) depending on the platform? I mean, it doesn't make any sense to have an OSX keybinding file on Windows or GNU/Linux, nor it would to have a Windows one on OSX, etc. Plus, it would make it easier to have specific keybindings on non-OSX in the future if wanted, without having to actually change the loading code.
The only "trick" would be to install an OSX-specific file on OSX, which should be reasonably easy to do.
techee commented on this pull request.
@@ -782,6 +768,36 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}
+static void init_platform_kb(void) +{ +#ifdef __APPLE__ + gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
The only reason was my disgust towards automake/autoconf and not really knowing how to do it...
b4n commented on this pull request.
@@ -782,6 +768,36 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}
+static void init_platform_kb(void) +{ +#ifdef __APPLE__ + gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
I suggest something like 28ac94dac806b2fed92c3c7406557341c978fbcd (https://github.com/b4n/geany/tree/techee/osx_keybindings_followup). To be tested if it properly detects OSX on an OSX system, but it should.
techee commented on this pull request.
@@ -782,6 +768,36 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}
+static void init_platform_kb(void) +{ +#ifdef __APPLE__ + gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
Great! I knew you wouldn't resist the temptation to mess with m4 :-)
But the patch doesn't do exactly the right thing. The point of my patch was to keep Geany's keybindings.conf and only override the keybindings which have to change inside keybindings_osx.conf so it doesn't have to change every time some new keybinding is added and it's easier to see only the changes. See the calls of init_default_kb() followed by init_system_kb() which does the overrides.
So what I assumed you had in mind in your original comment was to keep `keybindings.conf` as it is now but then on install time copy only the keybindings file specific to the used platform and rename it to e.g. `keybindings_patform.conf` which would be referenced in the sources so there wouldn't have to be any ifdefs and only one version of platform-specific keybindings would be installed.
Also I think it would be best to keep the platform-specific keybinding files inside the data dir in sources and not to move it under osx as they will usually have to be updated together.
Now the question is how hard this would be to do this and whether it's worth the work...
b4n commented on this pull request.
@@ -782,6 +768,36 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}
+static void init_platform_kb(void) +{ +#ifdef __APPLE__ + gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
@techee hum, we don't have a system-wide keybindings file yet, so I don't really see the difference between what I did and what you suggest? OK, if we wanted to have default keybindings in a system config file instead of hard-coded it would make sense (and it might be a good thing for the future), but unless I miss something we currently don't.
Also I think it would be best to keep the platform-specific keybinding files inside the data dir in sources and not to move it under osx as they will usually have to be updated together.
Yeah… well the problem is that Autotools don't make it easy to rename a file when installing it, hence the reason why I put it in a sub-directory so it can have the same name for each platform. But it's possible to do a rename, just not very nice. (yes, it's a sometimes annoying limitation of Autotools -- although generally renaming files means you could not use a non-installed version of your software, but well)
@b4n, one benefit of having the platform specific keybindings file is that it makes what is different on the platform clearly visible, and so easier to maintain.
@techee wasn't this triggered by some issue, shouldn't you make the platform keybindings file to address that as part of the PR?
@b4n, one benefit of having the platform specific keybindings file is that it makes what is different on the platform clearly visible, and so easier to maintain.
Yes, and what I proposed kept that the same. But we *do not* have a system-wide, non-platform-specific keybindings file yet, so I don't replace anything.
But we do not have a system-wide, non-platform-specific keybindings file yet, so I don't replace anything.
Oh, right, its in the code, of dear.
techee commented on this pull request.
@@ -782,6 +768,36 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}
+static void init_platform_kb(void) +{ +#ifdef __APPLE__ + gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
Meh, my bad, I haven't looked at the code for ages and completely forgot the defaults were in the code, not a config file.
The config file location probably isn't a big problem, especially when there's no Windows config file (which may never be needed) and no system-wide config file. So I guess your patch is good then.
@techee pushed 1 commit.
28ac94d Make system keybindings configuration more generic
https://github.com/geany/geany/pull/1633 fixes the majority of non-working keybindings.
The ones that still don't work and should be changed are
``` GEANY_KEYS_EDITOR_AUTOCOMPLETE GEANY_KEYS_SELECT_WORD GEANY_KEYS_GOTO_LINE GEANY_KEYS_GOTO_LINESTARTVISUAL GEANY_KEYS_GOTO_LINEENDVISUAL GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED ```
These don't work because of conflicts with system keybindings or because Alt-<some key> causes different character is created.
However, other keybindings should be changed too. For instance "delete to line end" is `<Primary><Shift><Delete>` but because there's no `<Delete>` on Mac, one has to press 4 keys `<Primary><Shift><Fn><Backspace>`, which is crazy.
Googling for 'geany mac os select till end of line' brought me to this thread, where I realize the last post was more than a year ago. Are there now keyboard shortcuts to select till beginning/end of line on mac os? As one of the posters pointed out, there's no home or end key on mac keyboards. I'm happy to customize my keybindings.conf if I know what the name of the entry should be.
The standard keybindings for home and end are Fn+<left arrow> and Fn+<right arrow> on mac which work in most editors, including Geany. I'm afraid this keybinding currently isn't overridable in Geany and is hard-coded in the Scintilla editing component Geany uses.
Except that Fn+Left and Fn+Right do not work as Home and End in Geany on my mac (they do nothing). So I have to do Cmd+Left for Home, but Shift+Fn+Left to select to start of line. This is a discrepancy. I'm now realizing that this discrepancy also infects this text box I'm typing in in Firefox, but I don't know if it's the same root cause (scintilla).
Have you tried this build?
https://download.geany.org/snapshots/geany-1.36_osx.dmg
I'm not sure if the older version based on GTK2 works or not but at least on my machine, this GTK3 build seems to do the right thing.
If I select "About Geany", it says Geany 1.36, but it also says "Using GTK+ v2.24.32 and GLib v2.60.6 runtime libraries". Is that the build you're talking about? I'm asking because I don't have permissions to install stuff on my work computer (yes, it sucks), so I'd like to make sure that it's an update before asking an admin.
This mailing list post more or less explains what's going on with the GTK3 build
https://lists.geany.org/pipermail/users/2019-October/011099.html
I believe this build works better than the GTK2 one and for future releases I'll switch to GTK3.
OK, I installed the GTK3 build from https://download.geany.org/snapshots/geany-1.36_osx.dmg. The theming looks more consistent with the rest of my apps, which is good. However, the original problem about which I opened the issue is still there, and I can see it even without selecting any text.
- First, I disabled Geany's keyboard shortcuts to go to the start and end of a line, because I wanted to see what the "native" behavior would be on macos. - Neither Fn+left nor Fn+right do anything, i.e., the traditional keystrokes for "Home" and "End" on a mac do nothing. - Now, if I hit Cmd+left, I go to the beginning of a line. This is therefore analogous to 'Home' on a PC keyboard. - However, if I hit Cmd+right, I go to the end of the current word. This is *not* analogous to 'End' on a PC keyboard. - Selection is even stranger. Shift+Fn+left/Shift+Fn+right select to the beginning/end of a line, even though Fn+left/right do nothing.
So I wonder if there's any way to get consistent keystrokes for all of these, i.e., [key]+left/right go to the beginning/end of a line, and Shift+[key]+left/right select to the beginning/end of a line.
Any resolution to this issue? As a regular user of geany who is now forced to use a mac for development, this inconsistency is driving me nuts. I could learn new keystrokes, but there doesn't seem to be *any* keystroke by default to go to end of line!
Fn+Right arrow goes to the end of the line for me (corresponds to the default Home key keybinding). In Preferences->Keybindings->"go to end of line" you can reconfigure the keybinding to whatever you want.
OK, now I finally have a set of consistent keystrokes. My problem was that I wanted <some key> to get to the beginning/end of line, and <shift>+<some key> to select till beginning/end of line. By default, Fn+left did nothing, but shift+Fn+left selected till beginning of line, and so on, and there was no configurable keybinding in the preferences for "select till beginning/end of line". Now I've set "go to beginning/end of line" to be Fn+left/right in the preferences, which makes them consistent with the selection till beginning/end of line keystrokes.
Hi.
I'm using version 2.0 on a Mac at work. OS version is 14.7.
Reading this PR I cannot figure out whether at some point the system-wide shortcut `Ctrl+F2` ("Move focus to the menu bar") has been incorporated to Geany. It currently doesn't work, but it does if I'm on any other program window. This would be useful to access not key-bound menu entries by accessing the menu, in the same vein as one can access the View menu, for example, with `Alt+v` on Win/Linux.
Is there a trick somewhere in the System Preferences to make it work? Are there plans for incorporating this shortcut to Geany?
I see there is a `osx_keybindings` branch, and when this PR was created a file called `keybindings_osx.conf` is mentioned, but I do not have it on my Geany directory. Is there a way I can see an example of the entries for this file so I can test whether it works?
Thanks!
I don't think this is about adding some specific keybindings to Geany itself but rather that GTK (the UI library that Geany uses) swallows key events and doesn't pass them to the system. One would probably have to study GTK code to see what's going on there.
github-comments@lists.geany.org