From 8b5e1b5860f802d8878f3362ae7cf5c60c13f837 Mon Sep 17 00:00:00 2001 From: lhark Date: Thu, 16 Jul 2020 00:06:10 -0400 Subject: [PATCH] =?UTF-8?q?[vim]=20Add=20support=20for=20b=C3=A9po=20keybo?= =?UTF-8?q?ard=20layout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/detectbepo | Bin 0 -> 17080 bytes src/detectbepo.c | 53 ++++++++++++++++++++++++++++++ vim/bepo.rc | 83 +++++++++++++++++++++++++++++++++++++++++++++++ vimrc | 6 ++++ 4 files changed, 142 insertions(+) create mode 100755 bin/detectbepo create mode 100644 src/detectbepo.c create mode 100644 vim/bepo.rc diff --git a/bin/detectbepo b/bin/detectbepo new file mode 100755 index 0000000000000000000000000000000000000000..7d2485e983027bfecc889699e6b64cf50b84356c GIT binary patch literal 17080 zcmeHOe{dAl9e>FY2nd&eAk-h_iZT;yIT8poNRhpe3mXkTih;(duwL#iFeP0oo8B=aRIl|Bmxo%gs8y8hz6v{v^V1ei`)1W%p}f?o_?fEo ziY1+~wiUHYIwOlaWASv);-0z{i&xb8Qwjf4dET=T2=%FT8@7m^lRy3a0d3VUrk`C{ z{b+eh+cy8<>nU!Ef&7sU71Fn-b0&C_%k#1tmSVzJo*&?@2ySAT0mwHI7QY5ID-ZsS z0{Ec<_(uis4+`L+0{9}}KK$I}hXC@$883jpS^$5p0RCnHybibzKX=&-AYVMEfiG|? zgFlJiOfgUNX_k=h3xR&qT2n(EWrZ-BTGktpXfnDZmNKKsmi22p6Y*$EsI4<93}Z)E zB5tJ2P|`FEOEs@z>&~`yQS;VlZ(AaijEL5a-O+eMEY;l^>J_b!1k6O&hEP{jSc%@l${JmH;2xMQc$9*T8} zl$kUWJ3(+3Nzr~!G6v^{5$*{Y?Xh^MGqx*AI^nKvpyW}VP**4x7wejv>em`e{k6H; zQvY(9F6!nU+zYb1D}*_VmO%CtBzzywj>XXBJz{!^g{7~KO{Kf(D)3b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#include + +#include +#include + +int main(int argc, char **argv) { + Display *dpy = XOpenDisplay(NULL); + + if (dpy == NULL) { + fprintf(stderr, "Cannot open display\n"); + exit(-1); + } + + XkbStateRec state; + XkbGetState(dpy, XkbUseCoreKbd, &state); + + XkbDescPtr desc = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); + char *group = XGetAtomName(dpy, desc->names->groups[state.group]); + //printf("Full name: %s\n", group); + + XkbRF_VarDefsRec vd; + XkbRF_GetNamesProp(dpy, NULL, &vd); + + char *layout = strtok(vd.layout, ","); + + for (int i = 0; i < state.group; i++) { + layout = strtok(NULL, ","); + if (layout == NULL) { + return -1; + } + } + + //printf("Layout name: %s\n", tok); + if (strcmp(layout, "fr")) + return 1; + + char *variant = strtok(vd.variant, ","); + + for (int i = 0; i < state.group; i++) { + variant = strtok(NULL, ","); + if (variant == NULL) { + return -1; + } + } + //printf("Variant name: %s\n", variant); + if (strcmp(variant, "bepo")) + return 1; + + printf("Bépo détecté\n"); + return 0; +} diff --git a/vim/bepo.rc b/vim/bepo.rc new file mode 100644 index 0000000..91839ee --- /dev/null +++ b/vim/bepo.rc @@ -0,0 +1,83 @@ +" From https://bepo.fr/wiki/Vim +" +" {W} -> [É] +" —————————— +" On remappe W sur É : +noremap é w +noremap É W +" Corollaire: on remplace les text objects aw, aW, iw et iW +" pour effacer/remplacer un mot quand on n’est pas au début (daé / laé). +onoremap aé aw +onoremap aÉ aW +onoremap ié iw +onoremap iÉ iW +" Pour faciliter les manipulations de fenêtres, on utilise {W} comme un Ctrl+W : +noremap w +noremap W + +" [HJKL] -> {CTSR} +" ———————————————— +" {cr} = « gauche / droite » +noremap c h +noremap r l +" {ts} = « haut / bas » +noremap t j +noremap s k +" {CR} = « haut / bas de l'écran » +noremap C H +noremap R L +" {TS} = « joindre / aide » +noremap T J +noremap S K +" Corollaire : repli suivant / précédent +noremap zs zj +noremap zt zk + +" {HJKL} <- [CTSR] +" ———————————————— +" {J} = « Jusqu'à » (j = suivant, J = précédant) +noremap j t +noremap J T +" {L} = « Change » (l = attend un mvt, L = jusqu'à la fin de ligne) +noremap l c +noremap L C +" {H} = « Remplace » (h = un caractère slt, H = reste en « Remplace ») +noremap h r +noremap H R +" {K} = « Substitue » (k = caractère, K = ligne) +noremap k s +noremap K S +" Corollaire : correction orthographique +noremap ]k ]s +noremap [k [s + +" Désambiguation de {g} +" ————————————————————— +" ligne écran précédente / suivante (à l'intérieur d'une phrase) +noremap gs gk +noremap gt gj +" onglet précédent / suivant +noremap gb gT +noremap gé gt +" optionnel : {gB} / {gÉ} pour aller au premier / dernier onglet +noremap gB :exe "silent! tabfirst" +noremap gÉ :exe "silent! tablast" +" optionnel : {g"} pour aller au début de la ligne écran +noremap g" g0 + +" <> en direct +" ———————————— +noremap « < +noremap » > + +" Remaper la gestion des fenêtres +" ——————————————————————————————— +noremap wt j +noremap ws k +noremap wc h +noremap wr l +noremap wd c +noremap wo s +noremap wp o +noremap w :split +noremap w :vsplit diff --git a/vimrc b/vimrc index f46a365..66f3f71 100644 --- a/vimrc +++ b/vimrc @@ -297,3 +297,9 @@ if has("autocmd") endif endif " has("autocmd") + +" Enable bépo layout if detected +silent call system("detectbepo") +if v:shell_error == 0 + source ~/.vim/bepo.rc +endif