Questions tagged [readline]

A library for command line editing, or a function to read one line of text.

Readline may refer either the GNU readline library, used for editing a command line; or a function or method in various programming languages which typically reads a line of text from an open file handle.

GNU readline library

The gnu readline library provides applications with an interactive command prompt with features like

  • flexible command editing
  • configurable key bindings to mimic e.g. or
  • a history of past commands

Probably the most prominent application using readline is . Both packages are maintained by the same person. Many programming languages provide bindings for this library.

readline function

Examples of readline functions or methods include

(please extend this list if you know more languages using this name)

2233 questions
7
votes
2 answers

How to make python autocompletion display matches?

I have kind of a completer class with an autocompletion function. Simple version: class Completer: def __init__(self): self.words = ["mkdir","mktbl", "help"] self.prefix = None def complete(self, prefix, index): if…
MajesticRa
  • 13,770
  • 12
  • 63
  • 77
7
votes
1 answer

TypeScript + NodeJS readline property missing

I'm working on a small project in TypeScript with tsc -v 2.4.2 and Node v6.10.3. I would like to capture keypresses in the CLI, so I tried to import * as readline from 'readline' and then later use readline.emitKeyPressEvents(process.stdin), but it…
Mori no Ando
  • 192
  • 4
  • 13
7
votes
3 answers

What value does readline return when reaching the end of the file in Python?

One can use the classic loop file_in = open('suppliers.txt', 'r') line = file_in.readline() while line: line = file_in.readline() to read through a file line-by-line in Python. But what value does 'line' have when the loop exits? The Python 3…
Josiah Yoder
  • 3,321
  • 4
  • 40
  • 58
7
votes
1 answer

Test interaction with users in R package

I am developing an R package and one of the function implements interaction with users through standard input via readline. I now wonder how to test the behavior of this function, preferably with testthat library. It seems test_that function…
Kota Mori
  • 6,510
  • 1
  • 21
  • 25
7
votes
1 answer

Why does my python interactive console not work properly?

I made a very simple interactive console that I'd like to use in a complicated scraping application. It looks like this: #!/usr/bin/env python # -*- coding: utf-8 -*- import os, sys, codecs, code sys.__stdout__ =…
user376403
  • 1,085
  • 2
  • 9
  • 18
7
votes
1 answer

Persistent history in python cmd module

Is there any way to configure the CMD module from Python to keep a persistent history even after the interactive shell has been closed? When I press the up and down keys I would like to access commands that were previously entered into the shell on…
PJConnol
  • 119
  • 1
  • 9
7
votes
4 answers

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…
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
7
votes
1 answer

Read lines from big text file in Swift until new line is empty: the Swift way

I have the following text file structure (the text file is pretty big, around 100,000 lines): A|a1|111|111|111 B|111|111|111|111 A|a2|222|222|222 B|222|222|222|222 B|222|222|222|222 A|a3|333|333|333 B|333|333|333|333 ... I need to extract a…
Igor Tupitsyn
  • 1,193
  • 3
  • 18
  • 45
7
votes
1 answer

Autocomplete with readline in python3

I'm trying to use this nifty trick here to work with a csv file. I can't seem to get autocomplete working in python3 though. I don't know where to begin with readline. The documentation was a little dense. My guess is that I'm missing something…
mrKelley
  • 3,365
  • 2
  • 21
  • 28
7
votes
4 answers

Is there a .Net library similar to GNU readline?

I'm considering writing a console application in C# and I want to incorporate history, completion and command line editing features something like GNU readline (but not necessarily as extensive as that!) Is there an existing library for .net which…
Paul Moore
  • 6,569
  • 6
  • 40
  • 47
7
votes
1 answer

Communicate with subprocess without waiting for the subprocess to terminate on windows

I have a simple echoprocess.py: import sys while True: data = sys.stdin.read() sys.stdout.write("Here is the data: " + str(data)) And a parentprocess.py from subprocess import Popen, PIPE proc = Popen(["C:/python27/python.exe",…
Michael David Watson
  • 3,028
  • 22
  • 36
7
votes
6 answers

GNU Readline: how to clear the input line?

I use GNU Readline in the "select" fashion, by registering a callback function like so: rl_callback_handler_install("", on_readline_input); And then hooking up rl_callback_read_char as the callback for my select() loop for STDIN_FILENO. That's all…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
7
votes
4 answers

Prefill a line with jline

Using either JLine (or JLine2), is it possible to issue a call to readline on a ConsoleReader and have, in addition to the standard prompt, the buffer be pre-filled with a string of my choosing? I have tried to do,…
Philippe
  • 9,582
  • 4
  • 39
  • 59
7
votes
3 answers

python tab completion in windows

I'm writing a cross-platform shell like program in python and I'd like to add custom tab-completion actions. On Unix systems I can use the built-in readline module and use code like the following to specify a list of possible completions when I hit…
Nate
  • 6,779
  • 8
  • 28
  • 21
7
votes
1 answer

Installing readline 6.0 on OS X

I'm trying to install readline 6 from source but run into an error during 'make install'. Here is the end of the output after executing 'sudo make install' ( cd shlib ; make DESTDIR= install ) /bin/sh ../support/mkdirs /usr/local/lib /bin/sh…
Paul
  • 673
  • 1
  • 6
  • 12