Skip to content
Snippets Groups Projects
Commit 5b4d99b5 authored by Marcus Comstedt's avatar Marcus Comstedt
Browse files

New function edit() that allows a default string to be put on the edit line.

Rev: lib/modules/Stdio.pmod/Readline.pike:1.19
parent ab8790b5
Branches
Tags
No related merge requests found
// $Id: Readline.pike,v 1.18 1999/06/06 09:05:48 mirar Exp $ // $Id: Readline.pike,v 1.19 1999/06/09 16:23:31 marcus Exp $
class OutputController class OutputController
{ {
...@@ -1246,21 +1246,27 @@ void set_blocking() ...@@ -1246,21 +1246,27 @@ void set_blocking()
set_nonblocking(0); set_nonblocking(0);
} }
string read() string edit(string data, string|void local_prompt)
{ {
if(newline_func == read_newline) if(newline_func == read_newline)
return 0; return 0;
function oldnl = newline_func; function oldnl = newline_func;
output_controller->write(prompt); output_controller->write(local_prompt||prompt);
initline(); initline();
newline_func = read_newline; newline_func = read_newline;
readtext = ""; readtext = "";
output_controller->enable(); output_controller->enable();
insert(data, 0);
int res = input_controller->run_blocking(); int res = input_controller->run_blocking();
set_nonblocking(oldnl); set_nonblocking(oldnl);
return (res>=0 || sizeof(readtext)) && readtext; return (res>=0 || sizeof(readtext)) && readtext;
} }
string read(string|void prompt)
{
return edit("", prompt);
}
void enable_history(object(History)|int hist) void enable_history(object(History)|int hist)
{ {
if (objectp(hist)) if (objectp(hist))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment