bugGNU Octave - Bugs: bug #63400, [MXE Octave] Arrow keys not...

 
 

bug #63400: [MXE Octave] Arrow keys not working in CLI

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Tue 22 Nov 2022 01:24:49 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Microsoft Windows
Fixed Release:  8.1.0 Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 14 Dec 2022 12:33:21 PM UTC, comment #10: 

Seems to be working now.

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Mon 28 Nov 2022 12:56:08 PM UTC, comment #9: 

I pushed a follow-up change here that hopefully helps to avoid false-positive detection of UTF-16 surrogate halves:
https://hg.octave.org/mxe-octave/rev/54f336bbb833

Markus Mützel <mmuetzel>
Group administrator
Sun 27 Nov 2022 06:39:47 PM UTC, comment #8: 

Given that we are close to a new major release, I figured it might be a good idea to push this as early as possible. This will hopefully allow people to test any effects even if they don't cross-build with MXE Octave themselves by using the mxe-default build from the nightlies:
https://buildbot.octave.space/#/download

I pushed the patch with minor cosmetic changes to the default branch of MXE Octave here:
https://hg.octave.org/mxe-octave/rev/a76f513700df

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Sat 26 Nov 2022 05:20:19 PM UTC, comment #7: 

I tried to better understand what the readline patches are actually doing. In particular, the patch "readline-2-event-hook.patch".

I believe I got it to a point where the arrow keys are working again in the CLI (and the GUI). Also, it is now possible to enter non-ASCII characters in the command window. And random non-ASCII characters no longer lead to crashes of the console host for me. 🎉

I don't know if any of those changes depend on a certain Windows version. The used functions (`ReadConsoleInputW` and `WideCharToMultiByte`) should be available in Windows 2000 and newer. I don't know if the characteristics of the console changed at some point though. I am on Windows 11 if that should be important.

I'm attaching a patch with the changes for MXE Octave. I'd appreciate if someone could test them. (Maybe on other Windows versions?)
Also, any proof-reading would be much appreciated.


(file #54025)

Markus Mützel <mmuetzel>
Group administrator
Tue 22 Nov 2022 05:45:22 PM UTC, comment #6: 

The following additional change fixes it for me for the MinGW readline in MSYS2:

--- readline-8.2/nls.c.orig        2022-08-15 15:38:51.000000000 +0200
+++ readline-8.2/nls.c        2022-11-22 18:37:21.816799800 +0100
@@ -141,8 +141,10 @@
   if (lspec == 0)
     lspec = "";
   ret = setlocale (LC_CTYPE, lspec);        /* ok, since it does not change locale */
+#if !defined (__MINGW32__)
   if (ret == 0 || *ret == 0)
     ret = setlocale (LC_CTYPE, (char *)NULL);
+#endif
   if (ret == 0 || *ret == 0)
     ret = RL_DEFAULT_LOCALE;
 #else


Maybe, that will also help for our version of it.

Markus Mützel <mmuetzel>
Group administrator
Tue 22 Nov 2022 04:24:37 PM UTC, comment #5: 

That didn't change anything unfortunately.

Testing in the MINGW64 environment of MSYS2, it works if I start Octave with `LC_CTYPE=C octave`. Not sure why that makes a difference though...

Markus Mützel <mmuetzel>
Group administrator
Tue 22 Nov 2022 03:37:15 PM UTC, comment #4: 

yep - if that would then call the internal function

John Donoghue <lostbard>
Group Member
Tue 22 Nov 2022 02:29:12 PM UTC, comment #3: 

Maybe, we'll need this additional diff:

--- a/input.c.orig
+++ b/input.c
@@ -411,7 +411,7 @@ _rl_input_available (void)

 #if defined (__MINGW32__)
   if (isatty (tty))
-    return (_kbhit ());
+    return (_win32_kbhit ());
 #endif

   return 0;


Markus Mützel <mmuetzel>
Group administrator
Tue 22 Nov 2022 02:21:56 PM UTC, comment #2: 

Unfortunately, the MSYS2 package is also broken for native MinGW:
https://github.com/msys2/MINGW-packages/issues/14213

I tried to get our patches accepted by MSYS2. But I couldn't make a good case as to why they are needed. They adopted only those for which I understood what they do.

The readline-2-event-hook.patch applied without changes to the updated tarball. Admittedly, I didn't look much into whether it applied correctly or whether further changes might be necessary.

Markus Mützel <mmuetzel>
Group administrator
Tue 22 Nov 2022 02:10:22 PM UTC, comment #1: 

readline has had a lot of stuff patched to make it work correctly.

If I understand it currently, readline-2-event-hook.patch adds a _win32_getch_internal function that gets called from rl_getc that handles the key input.

Somehow not being called any more?


Looking at the msys2 package, they have less patches than us, but have maybe combined some together? [1]


[1] https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-readline



John Donoghue <lostbard>
Group Member
Tue 22 Nov 2022 01:24:49 PM UTC, original submission:  

When opening the CLI with `octave-launch --no-gui` with a build from the default branch of MXE Octave, the arrow keys aren't working. Instead of browsing the command history or moving the cursor to the left or right, some characters are appearing at the command line.
With the GUI, the arrow keys still work properly.

That might be related to the update of readline to version 8.2:
https://hg.octave.org/mxe-octave/rev/5ef7d51c2195

One way to "fix" this might be to revert to readline 8.1.

CC'ing John Donoghue in case he has an idea how to "properly" fix this with readline 8.2.

Markus Mützel <mmuetzel>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by mmuetzel (Submitted the item)
  • -email is unavailable- added by mmuetzel
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-14 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 8.1.0
    2022-11-27 mmuetzel StatusPatch Submitted Ready For Test
    2022-11-26 mmuetzel Attached File- Added bug63400-readline-unicode.patch, #54025
        StatusNone Patch Submitted
    2022-11-22 mmuetzel Carbon-Copy- Added lostbard

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code