//
// Complete set of Romanian keyboards as described in the new Romanian standard
// SR 13392:2004 adopted in December 2004 by ASRO, "Asociatia de Standardizare 
// din Romania".
// 
// The default mapping is the Programmers layout (also known as RO_US) because
// of the lack of Romanian hardware keyboards. The primary standard layout is
// implemented as the "std" variant.
//
// Diacritics with cedillas, as in ISO-8859-2, are no longer supported. This
// error has been corrected in ISO-889-16 through using commabelow accents.
// Pre-Vista MS compatible layout ("winkeys" variant) generates commabelow
// accents too now.
// 
// Created by Cristian Gafton, <gafton@redhat.com> (C) 2000
// Modified by Marius Andreiana, <mandreiana@yahoo.com> (C) 2001
// Completed by Dumitru Moldovan, <dumol@gnome.org> (C) 2001, 2004-2008, 2020


default partial alphanumeric_keys
xkb_symbols "basic" {
// This RO_US/Programmers layout, although the secondary layout in the 
// Romanian standard, has always been the "de facto" standard in the 
// Linux/Unix world. It is implemented here as the default layout and it's
// fully compatible with an US keyboard (Euro on AltGr+5 does not count).

    include "us"

    name[Group1]="Romanian";

    key <AE01> { [            1,      exclam,       dead_tilde              ] };
    key <AE02> { [            2,          at,       dead_caron              ] };
    key <AE03> { [            3,  numbersign,  dead_circumflex              ] };
    key <AE04> { [            4,      dollar,       dead_breve              ] };
    key <AE05> { [            5,     percent,   dead_abovering              ] };
    key <AE06> { [            6, asciicircum,      dead_ogonek              ] };
    key <AE07> { [            7,   ampersand,       dead_grave              ] };
    key <AE08> { [            8,    asterisk,    dead_abovedot              ] };
    key <AE09> { [            9,   parenleft,       dead_acute              ] };
    key <AE10> { [            0,  parenright, dead_doubleacute              ] };
    key <AE11> { [        minus,  underscore,   dead_diaeresis,      endash ] };
    key <AE12> { [        equal,        plus,     dead_cedilla,   plusminus ] };
    key <AD01> { [            q,           Q,      acircumflex, Acircumflex ] };
    key <AD02> { [            w,           W,           ssharp,       U1e9e ] };
    key <AD03> { [            e,           E,         EuroSign              ] };
    key <AD05> { [            t,           T,            U021b,       U021a ] };
    key <AD08> { [            i,           I,      icircumflex, Icircumflex ] };
    key <AD10> { [            p,           P,          section              ] };
    key <AD11> { [  bracketleft,   braceleft, doublelowquotemark            ] };
    key <AD12> { [ bracketright,  braceright, rightdoublequotemark          ] };
    key <AC01> { [            a,           A,           abreve,      Abreve ] };
    key <AC02> { [            s,           S,            U0219,       U0218 ] };
    key <AC03> { [            d,           D,          dstroke,     Dstroke ] };
    key <AC09> { [            l,           L,          lstroke,     Lstroke ] };
    key <LSGT> { [    backslash,         bar                                ] };
    key <AB03> { [            c,           C,        copyright              ] };
    key <AB08> { [        comma,        less,    guillemotleft              ] };
    key <AB09> { [       period,     greater,   guillemotright              ] };

    key <KPDL> { [    KP_Delete,  KP_Decimal,    KP_Separator, KP_Separator ] };

    include "level3(ralt_switch)"
};


partial alphanumeric_keys
xkb_symbols "std" {
    // Primary layout in the new Romanian standard.
    // Implemented here as a variant because of the lack of hardware 
    // Romanian keyboards and because of the predilection of Romanian
    // X users towards the secondary layout from the new standard.

    include "us"

    name[Group1]="Romanian (standard)";

    key <TLDE> { [ doublelowquotemark, rightdoublequotemark, grave, asciitilde ] };
    key <AE01> { [            1,      exclam,       dead_tilde              ] };
    key <AE02> { [            2,          at,       dead_caron              ] };
    key <AE03> { [            3,  numbersign,  dead_circumflex              ] };
    key <AE04> { [            4,      dollar,       dead_breve              ] };
    key <AE05> { [            5,     percent,   dead_abovering              ] };
    key <AE06> { [            6, asciicircum,      dead_ogonek              ] };
    key <AE07> { [            7,   ampersand,       dead_grave              ] };
    key <AE08> { [            8,    asterisk,    dead_abovedot              ] };
    key <AE09> { [            9,   parenleft,       dead_acute              ] };
    key <AE10> { [            0,  parenright, dead_doubleacute              ] };
    key <AE11> { [        minus,  underscore,   dead_diaeresis,      endash ] };
    key <AE12> { [        equal,        plus,     dead_cedilla,   plusminus ] };
    key <AD03> { [            e,           E,         EuroSign              ] };
    key <AD10> { [            p,           P,          section              ] };
    key <AD11> { [       abreve,      Abreve,      bracketleft,   braceleft ] };
    key <AD12> { [  icircumflex, Icircumflex,     bracketright,  braceright ] };
    key <BKSL> { [  acircumflex, Acircumflex,        backslash,         bar ] };
    key <AC02> { [            s,           S,           ssharp,       U1e9e ] };
    key <AC03> { [            d,           D,          dstroke,     Dstroke ] };
    key <AC09> { [            l,           L,          lstroke,     Lstroke ] };
    key <AC10> { [        U0219,       U0218,        semicolon,       colon ] };
    key <AC11> { [        U021b,       U021a,       apostrophe,    quotedbl ] };
    key <LSGT> { [    backslash,         bar                                ] };
    key <AB03> { [            c,           C,        copyright              ] };
    key <AB08> { [        comma,   semicolon,           less, guillemotleft ] };
    key <AB09> { [       period,       colon,       greater, guillemotright ] };

    key <KPDL> { [    KP_Delete, KP_Separator,      KP_Decimal,  KP_Decimal ] };

    include "level3(ralt_switch)"
};


partial alphanumeric_keys
xkb_symbols "winkeys" {
    // Romanian (Legacy) QWERTZ keyboard layout, as available on Windows 10,
    // but with the correct commabelow accents and the Euro sign on AltGr+e.
    // Some Romanian hardware keyboards are still built like this.
    // Older Romanian hardware keyboards might be slightly different.
    // Created by Manfred Pohler, <Manfred.Pohler@t-online.de> (C) 2003
    // Updated by Dumitru Moldovan, <dumol@gnome.org> (C) 2020

    include "us"

    name[Group1]="Romanian (Windows)";

    key <TLDE> { [ bracketright, bracketleft                                ] };
    key <AE01> { [            1,      exclam,       asciitilde              ] };
    key <AE02> { [            2,    quotedbl,       dead_caron              ] };
    key <AE03> { [            3,  numbersign,  dead_circumflex              ] };
    key <AE04> { [            4,    currency,       dead_breve              ] };
    key <AE05> { [            5,     percent,   dead_abovering              ] };
    key <AE06> { [            6,   ampersand,      dead_ogonek              ] };
    key <AE07> { [            7,       slash,       dead_grave              ] };
    key <AE08> { [            8,   parenleft,    dead_abovedot              ] };
    key <AE09> { [            9,  parenright,       dead_acute              ] };
    key <AE10> { [            0,       equal, dead_doubleacute              ] };
    key <AE11> { [         plus,    question,   dead_diaeresis              ] };
    key <AE12> { [   apostrophe,    asterisk,     dead_cedilla              ] };
    key <AD01> { [            q,           Q,        backslash              ] };
    key <AD02> { [            w,           W,              bar              ] };
    key <AD03> { [            e,           E,         EuroSign              ] };
    key <AD06> { [            z,           Z                                ] };
    key <AD11> { [       abreve,      Abreve,         division              ] };
    key <AD12> { [  icircumflex, Icircumflex,         multiply              ] };
    key <AC02> { [            s,           S,          dstroke              ] };
    key <AC03> { [            d,           D,          Dstroke              ] };
    key <AC08> { [            k,           K,          lstroke              ] };
    key <AC09> { [            l,           L,          Lstroke              ] };
    key <AC10> { [        U0219,       U0218,           dollar              ] };
    key <AC11> { [        U021b,       U021a,           ssharp              ] };
    key <BKSL> { [  acircumflex, Acircumflex                                ] };
    key <LSGT> { [         less,     greater                                ] };
    key <AB01> { [            y,           Y                                ] };
    key <AB04> { [            v,           V,               at              ] };
    key <AB05> { [            b,           B,        braceleft              ] };
    key <AB06> { [            n,           N,       braceright              ] };
    key <AB07> { [            m,           M,          section              ] };
    key <AB08> { [        comma,   semicolon,             less              ] };
    key <AB09> { [       period,       colon,          greater              ] };
    key <AB10> { [        minus,  underscore                                ] };

    key <KPDL> { [    KP_Delete, KP_Separator,      KP_Decimal,  KP_Decimal ] };

    include "level3(ralt_switch)"
};


// EXTRAS:


partial
xkb_symbols "crh_dobruja" {
    // Romania-specific Crimean Tatar (Crimean Turkish) Q layout.
    // This layout is not yet standard. Common Alt-Q and F layouts are now also 
    // available right next to this layout in the new language-centric UI.
    // Reşat SABIQ <tilde.birlik @ gmail . com>, 2009, 2011
    // Özgür Qarahan <qarahan @ gmail . com>, 2009

    include "ua(crh)"

    name[Group1]="Crimean Tatar (Dobruja Q)";

    key <AD02> { [            w,           W,           abreve,       Abreve ] };
    key <AD05> { [            t,           T,            U021b,        U021a ] };
    key <AD10> { [            p,           P,          section               ] };
    key <AC02> { [            s,           S,            U0219,        U0218 ] };
    key <AC07> { [       ibreve,      Ibreve,                j,            J ] };
    key <AB07> { [            m,           M,        trademark,    masculine ] };
};


partial alphanumeric_keys
xkb_symbols "ergonomic" {
    // This layout is optimized for fast touch-typing in Romanian on a
    // US keyboard, and works by swapping out symbols infrequently used
    // in written Romanian (q,w,y,k) in favor of native ones, thus reducing
    // the need to use modifier keys.
    // Created by Gabriel Somlo, <somlo@cmu.edu> (C) 2011

    include "ro(basic)"

    name[Group1]="Romanian (ergonomic Touchtype)";

    key <AD01> { [       abreve,      Abreve,                q,           Q ] };
    key <AD02> { [        U0219,       U0218,                w,           W ] };
    key <AD06> { [        U021b,       U021a,                y,           Y ] };
    key <AC01> { [            a,           A,      acircumflex, Acircumflex ] };
    key <AC08> { [  icircumflex, Icircumflex,                k,           K ] };
};


partial alphanumeric_keys
xkb_symbols "sun_type6" {
    include "sun_vndr/ro(sun_type6)"
};

//  >>--> DreymaR (OEystein Bech-Aase, formerly Bech Gadmar), 2012-01: Additions to xkb/symbols/ro
//  Colemak[eD]: National/locale Colemak "edition DreymaR" variants for Romanian.
//  2006-01-01  Shai Coleman  http://colemak.com/  (Public Domain)  : The Colemak keyboard layout.
//  See the Big Bag section on Cmk[eD] locales: https://dreymar.colemak.org/variants.html#locales

//  The 'keep local symbols' variant keeps the national symbol and special letter setup.
partial alphanumeric_keys
xkb_symbols "cmk_ed_ks" {
    include "ro(basic)"
    include "colemak(cmk_ed_letters)"
    name[Group1]= "Romanian (Colemak[eD], keep local symbols)";

//  NOTE: Symbols on letter keys may be lost in cmk_ed_ks if they are not on Colemak[eD] letter keys.
//  EuroSign is often on 'E'. The latin(intl) and locale(winkeys) layout variants use '5'.
//  Colemak[eD] has EuroSign on 'E' and mu on '5'.
//    key <AE05> { [ NoSymbol, NoSymbol,       mu, dead_abovering ] };
//    key <AE05> { [ NoSymbol, NoSymbol, EuroSign, dead_abovering ] }; // dead_abovering is moved

    key <AD10> { [ semicolon, colon, dead_diaeresis, ellipsis ] }; // Colemak[eD] <AD10>

//  NOTE: The Romanian standard layout has its locale letters on AltGr letter keys. Some have been converted here.
    key <AD01> { [ q,                      Q,  acircumflex,   Acircumflex ] };
    key <AD02> { [ w,                      W,  ssharp,	 	  any         ] };
    key <AD04> { [ p,                      P,  section, 	  any         ] };
    key <AD07> { [ l,                      L,  lstroke,  	  Lstroke     ] };
    key <AC01> { [ a,                      A,  abreve,        Abreve      ] };
    key <AC03> { [ s,                      S,  0x1000219,     0x1000218   ] };
    key <AC04> { [ t,                      T,  0x100021b,     0x100021a   ] };
    key <AC05> { [ d,                      D,  dstroke,  	  Dstroke     ] };
    key <AC09> { [ i,                      I,  icircumflex,   Icircumflex ] };
};

//  The 'us' variant uses the US-type symbol key setup (recommended!) as it is nearly an intl. standard.
//  For Romanian, necessary local letters are added to designated flexible spots in the layout.
//  For "writing" and "coding" subvariants, move the brackets between lv1-2 and lv3-4 as shown.
partial alphanumeric_keys
xkb_symbols "cmk_ed_us" {
    include "colemak(cmk_ed_letters)"
    include "symkeys(cmk_ed_symbols)"
    include "level3(ralt_switch)"
    name[Group1]= "Romanian (Colemak[eD], unified symbols)";

//  NEEDED: Circumflex A/I; breve A/I (the I for Crimean Tatars); commabelow S/T; stroke D/L (?)
//  Romanian letter frequencies: ă 2.3%(?); î 1.4%(?); others < 0.1%(?) (şţâ...). In ro(basic), all are lv3-4.
//  NOTE: Commabelow, not cedilla, is correct for S/T. The dead_cedilla key can produce the latter if desired.

//    key <AD11> { [   bracketleft,     braceleft,              abreve,              Abreve ] };
//    key <AD12> { [  bracketright,    braceright,         icircumflex,         Icircumflex ] };
    key <AD11> { [        abreve,        Abreve,         bracketleft,           braceleft ] }; // from 'a'
    key <AD12> { [   icircumflex,   Icircumflex,        bracketright,          braceright ] }; // from 'i'
    key <LSGT> { [   acircumflex,   Acircumflex,                  oe,                  OE ] }; // from 'q'
    key <AC03> { [             s,             S,           0x1000219,           0x1000218 ] }; // comma-s from 's'
    key <AC04> { [             t,             T,           0x100021b,           0x100021a ] }; // comma-t from 't'
    key <AC05> { [             d,             D,             dstroke,             Dstroke ] }; // from 'd'
//  NOTE: The Curl(DH) ergo mod moves H and K, which may interfere with these mappings.
    key <AC06> { [             h,             H,              ssharp,             section ] }; // from Cmk[eD] 's'
    key <AB06> { [             k,             K,              ibreve,              Ibreve ] }; // Crimean Tatar
    key <AD07> { [             l,             L,             lstroke,             Lstroke ] }; // from 'l'
};
//  <--<< DreymaR: Additions to xkb/symbols/ro
