+2018-10-06  Tom Tromey  <tom@tromey.com>
+
+       PR tui/28819:
+       * tui/tui-io.c (gdb_wgetch): New function.
+       (tui_mld_getc, tui_getc): Use it.
+
 2018-10-05  Tom Tromey  <tom@tromey.com>
 
        * sol-thread.c (sol_thread_target::wait): Rename inner
 
   beep ();
 }
 
+/* A wrapper for wgetch that enters nonl mode.  We We normally want
+  curses' "nl" mode, but when reading from the user, we'd like to
+  differentiate between C-j and C-m, because some users bind these
+  keys differently in their .inputrc.  So, put curses into nonl mode
+  just when reading from the user.  See PR tui/20819.  */
+
+static int
+gdb_wgetch (WINDOW *win)
+{
+  nonl ();
+  int r = wgetch (win);
+  nl ();
+  return r;
+}
+
 /* Helper function for tui_mld_read_key.
    This temporarily replaces tui_getc for use during tab-completion
    match list display.  */
 tui_mld_getc (FILE *fp)
 {
   WINDOW *w = TUI_CMD_WIN->generic.handle;
-  int c = wgetch (w);
+  int c = gdb_wgetch (w);
 
   return c;
 }
   tui_readline_output (0, 0);
 #endif
 
-  ch = wgetch (w);
+  ch = gdb_wgetch (w);
 
   /* The \n must be echoed because it will not be printed by
      readline.  */
       int ch_pending;
 
       nodelay (w, TRUE);
-      ch_pending = wgetch (w);
+      ch_pending = gdb_wgetch (w);
       nodelay (w, FALSE);
 
       /* If we have pending input following a start sequence, call the stdin