Community
    • Login

    cursor movement in right-to-left mode

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    arrow keyscursor movementright-to-left
    8 Posts 4 Posters 6.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Nir NagidN
      Nir Nagid
      last edited by

      Hi everyone,

      Arrow key navigation seems to be defined so that right arrow always moves the cursor FORWARD. This is counter-intuitive in RTL mode, as “forward” is now in the LEFT direction, and all other programs I know work that way. Would the developers consider changing this? In the meantime, can anyone help with a workaround? I.e. can the arrow keys be mapped differently for RTL and LTR modes?

      Thank you very much,
      Nir

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Nir Nagid
        last edited by

        @Nir-Nagid

        you could do it with a python script

        _g = globals()                                                                  # global variable used to check status
        if not _g.get('SWITCHED_TO_RTL'):                                               # if variable not defined yet,
            SWITCHED_TO_RTL = False 
        
        # ----------------------------------------------------------------------------- 
        
        def main():                                                                     # main function to handle start/stop behavior
            global SWITCHED_TO_RTL                                                      # assining to global variable
            if SWITCHED_TO_RTL:                                                         # if currently in RTL mode
                SWITCHED_TO_RTL = False                                                 #   set flag to False
                editor.assignCmdKey(KEYS.RIGHT,2306)                                    #   and remap arrow and
                editor.assignCmdKey(KEYS.LEFT,2304)                                     #   left arrow key to default                                                    
                notepad.menuCommand(MENUCOMMAND.EDIT_LTR)                               #   change view mode back to LTR
            else:                                                                       # else
                SWITCHED_TO_RTL = True                                                  #   set the flag to true
                editor.assignCmdKey(KEYS.RIGHT,2304)                                    #   and remap arrow and
                editor.assignCmdKey(KEYS.LEFT,2306)                                     #   left arrow key         
                notepad.menuCommand(MENUCOMMAND.EDIT_RTL)                               #   change view mode to LTR
        # ----------------------------------------------------------------------------- 
                
        main()
        

        When running the script for the first time it remaps the left and right arrow key and changes the view to RTL,
        next run would reverse the changes.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • Nir NagidN
          Nir Nagid
          last edited by

          Thank you very much Claudia, but I since realized the problem goes deeper (or is the following a separate problem?). The “push” mechanism for RTL languages in LTR mode is a bit screwy. Here’s an example: make sure you’re in LTR mode; on a blank line, enter “א”, space, “1”; on anther, enter “1”, space, “א”. Both lines look the same: “1 א” :(.

          Also, if you select the first letter in the first line, it LOOKS like the 1 is selected, but cut’n’paste it, and you’ll find the “real” first char, “א”, is the one that was selected.

          Developers? Workaround? Any other insights?

          Thank you,
          Nir

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • DaveyDD
            DaveyD
            last edited by

            I’ve been working with this problem for years now… Never found a workaround - I’d love it if there was, however, it seems like most programs have this problem. Microsoft Word is one of the only programs that deal with this excellently!

            1 Reply Last reply Reply Quote 0
            • Claudia FrankC
              Claudia Frank @Nir Nagid
              last edited by Claudia Frank

              @Nir-Nagid

              I think this is a problem of some of the lexers because if I try to do it and having python as language set it doesn’t happen.
              But if I have normal text as language, then it happens. You can workaround it by defining an empty udl and use it as “YOUR_NORMAL_TEXT”.

              Btw I guess there is a need to have more shortcuts reassigned. The once, I think, are useful are

              _g = globals()                                                                      # global variable used to check status
              if not _g.get('SWITCHED_TO_RTL'):                                                   # if variable not defined yet,
                  SWITCHED_TO_RTL = False 
              
              # ----------------------------------------------------------------------------- 
              
              def main():                                                                         # main function to handle start/stop behavior
                  global SWITCHED_TO_RTL                                                          # assining to global variable
                  if SWITCHED_TO_RTL:                                                             # if currently in RTL mode
                      SWITCHED_TO_RTL = False                                                     #   set flag to False (default)
                      editor.assignCmdKey(KEYS.LEFT, 2304)                                        #   char left                                                    
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.SHIFT << 16), 2305)                 #   char left extend
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.SHIFT + KEYMOD.ALT << 16), 2428)    #   char left rect extend
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.CTRL << 16), 2308)                  #   word left
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.SHIFT + KEYMOD.CTRL << 16), 2309)   #   word left extend
                      
                      editor.assignCmdKey(KEYS.RIGHT, 2306)                                       #   char right
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.SHIFT << 16), 2307)                #   char right extend
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.SHIFT + KEYMOD.ALT << 16), 2429)   #   char right rect extend
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.CTRL << 16), 2310)                 #   word right
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.SHIFT + KEYMOD.CTRL << 16), 2311)  #   word right extend
                      
                      notepad.menuCommand(MENUCOMMAND.EDIT_LTR)                                   #   change view mode back to LTR
                  else:                                                                           # else
                      SWITCHED_TO_RTL = True                                                      #   set the flag to true (RTL mode)
                      editor.assignCmdKey(KEYS.RIGHT, 2304)                                       #   
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.SHIFT << 16), 2305)                #   
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.SHIFT + KEYMOD.ALT << 16), 2428)   #   
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.CTRL << 16), 2308)                 #   
                      editor.assignCmdKey(KEYS.RIGHT + (KEYMOD.SHIFT + KEYMOD.CTRL << 16), 2309)  #   
                      
                      editor.assignCmdKey(KEYS.LEFT, 2306)                                        #   
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.SHIFT << 16), 2307)                 #   
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.SHIFT + KEYMOD.ALT << 16), 2429)    #   
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.CTRL << 16), 2310)                  #   
                      editor.assignCmdKey(KEYS.LEFT + (KEYMOD.SHIFT + KEYMOD.CTRL << 16), 2311)   #         
                      notepad.menuCommand(MENUCOMMAND.EDIT_RTL)                                   #   change view mode to RTL
              # ----------------------------------------------------------------------------- 
                      
              main()
              

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 2
              • YaronY
                Yaron
                last edited by

                Hello all,

                @Claudia,
                Welcome back. :)

                And thanks for the script.
                Two comments:

                1. editor1 and editor2 if you want to apply the keys to both views.
                2. Ctrl + (reassigned) Arrow does not work properly when using a RTL language in LTR mode (and vice versa).

                @Nir,
                Scintilla does not fully support RTL. We should raise the issue there more frequently.

                @Davey,
                EditPad is quite a good editor which fully supports RTL and bidi.
                You can set the behavior of the left/right arrows in Options -> Configure File Types -> Editor Options -> Default text layout -> Edit.
                (I use the PRO version).

                InsertText

                Best regards.

                1 Reply Last reply Reply Quote 0
                • DaveyDD
                  DaveyD
                  last edited by

                  @Yaron,
                  Hi and thanks for the suggestion.
                  My problem is that I am referring to coding - i.e., in my code I have Hebrew text (e.g. messages, dialogs etc.) and it’s extremely difficult to work with!
                  So, since I use n++ for coding (as I developed a custom syntax using UDL2 as well as functions hints and function list), using editPad is not really relevant in my case… unless there’s more there than I expect… :)

                  Thanks,
                  David

                  1 Reply Last reply Reply Quote 0
                  • YaronY
                    Yaron
                    last edited by

                    Hello David,

                    You’re welcome.

                    NPP is undoubtedly a great editor. Combining Latin and Hebrew, however, is much easier with EditPad.
                    It is a developer editor and you can set a custom syntax highlight.

                    I use a toolbar button in both editors to open the current file (and line) in the other editor.

                    In NPP:
                    <Command name="פתח ב- EditPad..." Ctrl="no" Alt="no" Shift="no" Key="0">&quot;C:\Program Files\EditPad Pro\EditPadPro7.exe&quot; &quot;$(FULL_CURRENT_PATH)&quot; /l$(CURRENT_LINE)</Command>

                    and in EditPad:
                    "C:\Program Files\Notepad++\NP\notepad++.exe" "%FILE%" -n%LINE%.

                    Best regards.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors