From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e6ae4808702f1c5e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!news2.volia.net!news-out.ntli.net!newsrout1-gui.ntli.net!ntli.net!news.highwinds-media.com!newspeer1-win.ntli.net!newsfe1-gui.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: Cursor control question - ncurses and alternatives User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Sat, 14 Oct 2006 02:38:22 GMT NNTP-Posting-Host: 82.10.238.153 X-Trace: newsfe1-gui.ntli.net 1160793502 82.10.238.153 (Sat, 14 Oct 2006 03:38:22 BST) NNTP-Posting-Date: Sat, 14 Oct 2006 03:38:22 BST Organization: NTL Xref: g2news2.google.com comp.lang.ada:6957 Date: 2006-10-14T02:38:22+00:00 List-Id: On Fri, 13 Oct 2006 22:41:52 +0000, Bj�rn Persson wrote: > Dr. Adrian Wrigley wrote: >> At the most basic level, I want to move the cursor to the start >> of the line, update the prompt, and move the cursor back to >> where it was. How can I do this? > > While there are escape sequences for querying, saving and restoring the > cursor position, I think you'll get the best result if you know what's > in the command buffer so that you can update the entire command line. > That means you'll have to do the line editing yourself. It could look > something like this: > There are most likely race conditions in that code, but I'm sure you can > fix that. You'll also need to decide what to do when the command line > gets so long that it wraps. To know whether it wraps you need to find > out how wide the window is. > > For advanced line editing you may want to look at the Readline library > at least for inspiration. Thank you for the outline code. I was beginning to see that the Text_IO.Get_Line might not work very well with concurrent screen updates because of race hazards. Readline is a good idea - it provides just the facilities a user would want in this application. Perhaps I can find a way of combining it with real-time data. If it can't do a real-time prompt out of the box, hacking the source code sounds possible. Building the string in memory like in your example might not give the best return on programmer time if an existing library can be a basis for a solution instead. I'll have another go tomorrow! -- Adrian