note 91769 added to function.readline-completion-function
| From: | overshoot dot tv at osu1 dot php dot net | Date: | Thu, 25 Jun 2009 07:07:03 +0000 |
| Subject: | note 91769 added to function.readline-completion-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157454@lists.php.net to get a copy of this message | ||
Note: the first argument passed to the registered function is NOT the whole command line as entered
by the user, but only the last part, i.e. the part after the last space.
e.g.:
<?php
function my_readline_completion_function($string, $index) {
// If the user is typing:
// mv file.txt directo[TAB]
// then:
// $string = directo
// the $index is the place of the cursor in the line:
// $index = 19;
$array = array(
'ls',
'mv',
'dar',
'exit',
'quit',
);
// Here, I decide not to return filename autocompletion for the first argument (0th argument).
if ($index) {
$ls =
ls;
$lines = explode("\n", $ls);
foreach ($lines AS $key => $line) {
if (is_dir($line)) {
$lines[$key] .= '/';
}
$array[] = $lines[$key];
}
}
// This will return both our list of functions, and, possibly, a list of files in the current
filesystem.
// php will filter itself according to what the user is typing.
return $array;
}
?>
P.S. The spam challenges are getting harder and harder:
Answer to this simple question (SPAM challenge): zero minus zero?
I guess that if you are reading this, it means I got the right answer!
----
Server IP: 140.112.2.5
Probable Submitter: 219.68.136.169
----
Manual Page -- http://www.php.net/manual/en/function.readline-completion-function.php
Edit -- https://master.php.net/note/edit/91769
Del: integrated -- https://master.php.net/note/delete/91769/integrated
Del: useless -- https://master.php.net/note/delete/91769/useless
Del: bad code -- https://master.php.net/note/delete/91769/bad+code
Del: spam -- https://master.php.net/note/delete/91769/spam
Del: non-english -- https://master.php.net/note/delete/91769/non-english
Del: in docs -- https://master.php.net/note/delete/91769/in+docs
Del: other reasons-- https://master.php.net/note/delete/91769
Reject -- https://master.php.net/note/reject/91769
Search -- https://master.php.net/manage/user-notes.php