readline

Is there a nice way of handling multi-line input with GNU readline?

My application has a command line interface, and I'm thinking about using the GNU Readline library to provide history, an editable command line, etc. The hitch is that my commands can be quite long and complex (think SQL) and I'd like to allow users to spread commands over multiple lines to make them more readable in the history. Is it...

How to read a line from the console in C

What is the simplest way to read a full line in a C console program The text entered might have a variable length and we can't make any assumption about its content. ...

Why is the Python readline module not available on OS X?

The documentation of the Python readline module says "Availability: Unix". However, it doesn't appear to be available on OS X, although other modules marked as Unix are available. Here is what I'm using: $ uname -a Darwin greg.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i38...

How to limit the number of characters read by StreamReader.ReadLine() in .NET?

I am writing a web server application in C# and using StreamReader class to read from an underlying NetworkStream: NetworkStream ns = new NetworkStream(clientSocket); StreamReader sr = new StreamReader(ns); String request = sr.ReadLine(); This code is prone to DoS attacks because if the attacker never disconnects we will never fini...

How to implement a python REPL that nicely handles asynchronous output?

I have a Python-based app that can accept a few commands in a simple read-eval-print-loop. I'm using raw_input('> ') to get the input. On Unix-based systems, I also import readline to make things behave a little better. All this is working fine. The problem is that there are asynchronous events coming in, and I'd like to print output as...

Why does my loop use 100% CPU and never end?

I have this method: private delegate void watcherReader(StreamReader sr); private void watchProc(StreamReader sr) { while (true) { string line = sr.ReadLine(); while (line != null) { if (stop) { return; } //Console.WriteLine(line)...

Is it possible to add multiple commands to the readline .inputrc file?

I'm trying to configure my Terminal and I would like to insert @{} at one key-stroke. This works with the following code # .inputrc "\e\"": "@{}" But I also want the cursor to end up inside the braces. How can I do this? The following doesn't work. # .inputrc "\e\"": "@{}": backward-char ...

How do I make IPython organize tab completion possibilities by class?

When an object has hundreds of methods, tab completion is hard to use. More often than not the interesting methods are the ones defined or overridden by the inspected object's class and not its base classes. How can I get IPython to group its tab completion possibilities so the methods and properties defined in the inspected object's cl...

Best way to verify readline input in C#?

Oh, 2 things: 1) It is a console application. 2 ) I know it is in danish, but it doesn't really matter, its just an example of asking for some input. The text and variables does not matter. Alright, consider this simple input: It could be any sort of input question really. Console.WriteLine("Hvad er dit kundenummer: (Kun hele tal tilla...

Best method for reading newline delimited files in Python and discarding the newlines?

I am trying to determine the best way to handle getting rid of newlines when reading in newline delimited files in Python. What I've come up with is the following code, include throwaway code to test. import os def getfile(filename,results): f = open(filename) filecontents = f.readlines() for line in filecontents: foo = ...

Press alt + numeric in bash and you get (arg [numeric]) what is that?

This is one of those questions where it is easier to ask someone else instead of spending thirty minutes trying to "guess" for the correct place in the documentation or search engine terms: Press alt + numeric in bash and you get (arg [numeric]) what is that? ...

Python assignment help: AttributeError: 'str' object has no attribute 'readline'

Update: My current question is how can I get my code to read to the EOF starting from the beginning with each new search phrase. This is an assignment I am doing and currently stuck on. Mind you this is a beginner's programming class using Python. jargon = open("jargonFile.txt","r") searchPhrase = raw_input("Enter the search phrase: ")...

Tab completion interrupt for large binaries

If I accidentally launch tab completion when debugging large binary, gdb will freeze for some time scanning symbol table (up to 1 minute in my case). So I have to wait until whole symbol table is scanned. Is there any way to interrupt this process in gdb? ...

Serial port dropping data with Readline()

I am using serial port to read the data off the scale that is attached to the thin client. In 99% of cases the data is read correctly - ie whatever is on the scale is what is captured by the application. However, sometimes, it looks like data is dropped. For instance instead of 90.007 it will be read as 0.007. I am using ReadLine functio...

C# StreamReader.ReadLine() - Need to pick up line terminators

I wrote a C# program to read an Excel .xls/.xlsx file and output to CSV and Unicode text. I wrote a separate program to remove blank records. This is accomplished by reading each line with StreamReader.ReadLine(), and then going character by character through the string and not writing the line to output if it contains all commas (for th...

In bash, how to make control-delete mean kill-word?

Bash uses readline, and readline can delete the word to the right of the cursor with "kill-word". The problem is in recognizing the keypress of control-delete. When I press them in bash, "5~" is output on the screen. I could just bind for this, but it would mean that one day I need to type "5~", and it deletes a word to the right in...

Using GNU Readline; how can I add ncurses in the same program?

The title is a bit more specific than my actual goal: I have a command-line program which uses GNU Readline, primarily for command history (i.e. retrieving previous commands using up-arrow) and some other niceties. Right now the program's output appears interspersed with the user's input, which sometimes is OK but the output is asynchr...

Installing ipython with readline on the mac

I am using ipython on Mac OS 10.5 with python 2.5.1 (I would actually like to use ipython for 2.6.1, but it doesn't seem to be available?) I installed ipython via easy_install. It works but is missing gnu readline (needed for nice searching of command line history with ctrl-R, etc.) I found a blog post and other sources saying this cou...

Reading a line from a streamreader without consuming?

Is there a way to read ahead one line to test if the next line contains specific tag data? I'm dealing with a format that has a start tag but no end tag. I would like to read a line add it to a structure then test the line below to make sure it not a new "node" and if it isn't keep adding if it is close off that struct and make a new o...

Saving a text file to a SQL database without column names

Hello, I am reading a text file in C# and trying to save it to a SQL database. I am fine except I don't want the first line, which is the names of the columns, included in the import. What's the easiest way to exclude these? The code is like this while (textIn.Peek() != -1) { string row = textIn.ReadLine(); string[] columns = r...