From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5093 invoked by alias); 23 Feb 2006 18:21:53 -0000 Received: (qmail 5084 invoked by uid 22791); 23 Feb 2006 18:21:51 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Thu, 23 Feb 2006 18:21:49 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FCL61-0007xB-Tj; Thu, 23 Feb 2006 13:21:46 -0500 Date: Thu, 23 Feb 2006 18:25:00 -0000 From: Daniel Jacobowitz To: Denis PILAT , Andrew STUBBS , Eli Zaretskii , gdb-patches@sources.redhat.com, bash-maintainers@gnu.org Subject: Re: [readline-mingw] backspace key and TUI size Message-ID: <20060223182145.GA25411@nevyn.them.org> Mail-Followup-To: Denis PILAT , Andrew STUBBS , Eli Zaretskii , gdb-patches@sources.redhat.com, bash-maintainers@gnu.org References: <20060208161452.GA26965@nevyn.them.org> <43EA201B.5080305@st.com> <20060208165114.GA28698@nevyn.them.org> <43EA2A39.4000107@st.com> <20060208173951.GA31572@nevyn.them.org> <43EB0CF9.1080406@st.com> <20060209134942.GA23253@nevyn.them.org> <43ECB429.6070003@st.com> <20060220153647.GA16058@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060220153647.GA16058@nevyn.them.org> User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00429.txt.bz2 On Mon, Feb 20, 2006 at 10:36:47AM -0500, Daniel Jacobowitz wrote: > FYI, the standard way to write this changelog entry would be: > > 2005-02-10 Denis Pilat > > * readline/terminal.c (_rl_get_screen_size): Get console size from > the Windows API when compiling with MinGW. Chet confirmed that he has taken a functionally equivalent patch for the next release of readline. So, I've committed the reformatted version of Denis's patch at the bottom of this message. This gets show width and show height to work on Windows consoles, and probably helps the TUI. However, it does not fix paging. I'm not planning to fix it, either - I wasted all morning on it. Here's the story in case someone else goes down the same rathole someday. First, GDB disables paging because tgetnum ("li") fails, so it assumes we're in a non-console environment. I could hack up win32-termcap.c to provide "li" if we're on a console, but that's not all... Next, readline sets cols to 79 instead of 80 because we don't have both automatic margins ("am") and ignored newlines beyond the automatic margins ("xn"). This causes utils.c to start printing the prompt at the last column of the previous line instead of the first column of the next line. In fact, we do have automatic margins, but we don't have "xn". So even if I hack up win32-termcap.c further to report "am", this still happens. I think it'll happen on any terminal without "xn", given the current logic in gdb and readline, whether or not the terminal has "am". But I don't know any other platform using such a terminal at the moment, so I don't want to rip up the guts of either readline or gdb to cope better. It's just not worth it. So since the only way I could get the paging prompt to work at all was graphically pretty nasty, and this console has scrollback anyway, I'm going to leave paging disabled. -- Daniel Jacobowitz CodeSourcery Index: src/readline/terminal.c =================================================================== --- src.orig/readline/terminal.c 2003-12-30 02:25:18.000000000 -0500 +++ src/readline/terminal.c 2006-02-23 10:44:00.000000000 -0500 @@ -70,6 +70,11 @@ #include "rlshell.h" #include "xmalloc.h" +#if defined (__MINGW32__) +# include +# include +#endif + #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) @@ -209,6 +214,20 @@ _rl_get_screen_size (tty, ignore_env) } #endif /* TIOCGWINSZ */ + /* For MinGW, we get the console size from the Windows API. */ +#if defined (__MINGW32__) + HANDLE hConOut = GetStdHandle (STD_OUTPUT_HANDLE); + if (hConOut != INVALID_HANDLE_VALUE) + { + CONSOLE_SCREEN_BUFFER_INFO scr; + if (GetConsoleScreenBufferInfo (hConOut, &scr)) + { + _rl_screenwidth = scr.dwSize.X; + _rl_screenheight = scr.srWindow.Bottom - scr.srWindow.Top + 1; + } + } +#endif + #if defined (__EMX__) _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight); #endif