Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
400e7e87
Commit
400e7e87
authored
26 years ago
by
David Hedbor
Browse files
Options
Downloads
Patches
Plain Diff
Added lowercase, uppercase and capitalize. Fixed backward word.
Rev: lib/modules/Stdio.pmod/Readline.pike:1.12
parent
fdf0693d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Stdio.pmod/Readline.pike
+55
-8
55 additions, 8 deletions
lib/modules/Stdio.pmod/Readline.pike
with
55 additions
and
8 deletions
lib/modules/Stdio.pmod/Readline.pike
+
55
−
8
View file @
400e7e87
// $Id: Readline.pike,v 1.1
1
1999/04/
1
2 0
2
:2
3:12 hubbe
Exp $
// $Id: Readline.pike,v 1.1
2
1999/04/2
5
0
8
:2
9:28 neotron
Exp $
class OutputController
class OutputController
{
{
...
@@ -545,7 +545,7 @@ class InputController
...
@@ -545,7 +545,7 @@ class InputController
class DefaultEditKeys
class DefaultEditKeys
{
{
static private multiset word_break_chars = mkmultiset("\t \n\r/*?_-.[]~&;\!#$%^(){}<>"/"");
static private multiset word_break_chars = mkmultiset("\t \n\r/*?_-.[]~&;\!#$%^(){}<>
\"
"/"");
static object _readline;
static object _readline;
void self_insert_command(string str)
void self_insert_command(string str)
...
@@ -618,6 +618,43 @@ class DefaultEditKeys
...
@@ -618,6 +618,43 @@ class DefaultEditKeys
_readline->insert(reverse(c), p-1);
_readline->insert(reverse(c), p-1);
}
}
array find_word_to_manipulate()
{
int p = _readline->getcursorpos();
int ep;
string line = _readline->gettext();
while(word_break_chars[ line[p..p] ] && p < strlen(line))
p++;
if(p >= strlen(line)) {
_readline->setcursorpos(p);
return ({ 0, 0 });
}
ep = forward_find_word();
_readline->delete(p, ep);
return ({ line[p..ep-1], p });
}
void capitalize_word()
{
[string word, string pos]= find_word_to_manipulate();
if(word)
_readline->insert(String.capitalize(lower_case(word)), pos);
}
void upper_case_word()
{
[string word, string pos]= find_word_to_manipulate();
if(word)
_readline->insert(upper_case(word), pos);
}
void lower_case_word()
{
[string word, string pos]= find_word_to_manipulate();
if(word)
_readline->insert(lower_case(word), pos);
}
int forward_find_word()
int forward_find_word()
{
{
int p, n;
int p, n;
...
@@ -632,13 +669,16 @@ class DefaultEditKeys
...
@@ -632,13 +669,16 @@ class DefaultEditKeys
int backward_find_word()
int backward_find_word()
{
{
int p = _readline->getcursorpos()
, n
;
int p = _readline->getcursorpos()
-1
;
string line = _readline->gettext();
string line = _readline->gettext();
if(p >= strlen(line)) p = strlen(line) - 1;
if(p >= strlen(line)) p = strlen(line) - 1;
for(; p >= 0; p--) {
while(word_break_chars[ line[p..p] ] && p >= 0)
// find first "non break char"
p--;
for(;p >= 0; p--)
if(word_break_chars[ line[p..p] ]) {
if(word_break_chars[ line[p..p] ]) {
if(n) break;
p++; // We want to be one char before the break char.
} else n = 1
;
break
;
}
}
return p;
return p;
}
}
...
@@ -657,9 +697,10 @@ class DefaultEditKeys
...
@@ -657,9 +697,10 @@ class DefaultEditKeys
{
{
_readline->delete(_readline->getcursorpos(), forward_find_word());
_readline->delete(_readline->getcursorpos(), forward_find_word());
}
}
void backward_delete_word()
void backward_delete_word()
{
{
int sp = backward_find_word()
+ 1
;
int sp = backward_find_word();
int ep = _readline->getcursorpos();
int ep = _readline->getcursorpos();
if((ep - sp) == 0)
if((ep - sp) == 0)
sp--;
sp--;
...
@@ -712,6 +753,12 @@ class DefaultEditKeys
...
@@ -712,6 +753,12 @@ class DefaultEditKeys
({ "\\!kd", down_history }),
({ "\\!kd", down_history }),
({ "\\!kr", forward_char }),
({ "\\!kr", forward_char }),
({ "\\!kl", backward_char }),
({ "\\!kl", backward_char }),
({ "^[C", capitalize_word }),
({ "^[c", capitalize_word }),
({ "^[U", upper_case_word }),
({ "^[u", upper_case_word }),
({ "^[L", lower_case_word }),
({ "^[l", lower_case_word }),
({ "^[D", forward_delete_word }),
({ "^[D", forward_delete_word }),
({ "^[^H", backward_delete_word }),
({ "^[^H", backward_delete_word }),
({ "^[^?", backward_delete_word }),
({ "^[^?", backward_delete_word }),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment