diff options
author | toonn <toonn@toonn.io> | 2021-01-22 20:29:36 +0100 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2021-01-22 20:29:36 +0100 |
commit | 6e78bbe39a5a5edecf6021788a63799333fa7e43 (patch) | |
tree | d1a6ecdac2e7713f633db706e90655bb19b6cc23 | |
parent | 73bcd80c1c3e721391c75015cb4ec03532357ad9 (diff) | |
parent | 785102b5b0da2828ade2e7752d151144ab7524f5 (diff) | |
download | ranger-6e78bbe39a5a5edecf6021788a63799333fa7e43.tar.gz |
Merge branch 'chu4ng-console-pos-flag'
-rw-r--r-- | doc/ranger.1 | 14 | ||||
-rw-r--r-- | doc/ranger.pod | 10 | ||||
-rwxr-xr-x | ranger/config/commands.py | 17 |
3 files changed, 28 insertions, 13 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index f675da91..e1c025ed 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.3" "2020-11-18" "ranger manual" +.TH RANGER 1 "ranger-1.9.3" "2021-01-22" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1247,7 +1247,7 @@ ranger. For your convenience, this is a list of the \*(L"public\*(R" commands i \& chain command1[; command2[; command3...]] \& chmod octal_number \& cmap key command -\& console [\-pSTARTPOSITION] command +\& console [\-pSTARTPOSITION | \-s SENTINEL] command \& copycmap key newkey [newkey2...] \& copymap key newkey [newkey2...] \& copypmap key newkey [newkey2...] @@ -1341,10 +1341,12 @@ example, \fB+ar\fR allows reading for everyone, \-ow forbids others to write and 777= allows everything. .Sp See also: man 1 chmod -.IP "console [\-p\fIN\fR] \fIcommand\fR" 2 -.IX Item "console [-pN] command" -Opens the console with the command already typed in. The cursor is placed at -\&\fIN\fR. +.IP "console [\-p\fIN\fR | \-s \fIsentinel\fR] \fIcommand\fR" 2 +.IX Item "console [-pN | -s sentinel] command" +Opens the console with the command already typed in. The cursor is placed at +\&\fIN\fR or at the first occurrence of \fIsentinel\fR. Note that sentinel strings can +potentially occur inside macro expansions. If you cannot provide a sentinel, +which is guaranteed to be unique, you should use \f(CW\*(C`\-p\*(C'\fR. .IP "copymap \fIkey\fR \fInewkey\fR [\fInewkey2\fR ...]" 2 .IX Item "copymap key newkey [newkey2 ...]" .PD 0 diff --git a/doc/ranger.pod b/doc/ranger.pod index bbdfd24e..4cd5335a 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1347,7 +1347,7 @@ ranger. For your convenience, this is a list of the "public" commands including chain command1[; command2[; command3...]] chmod octal_number cmap key command - console [-pSTARTPOSITION] command + console [-pSTARTPOSITION | -s SENTINEL] command copycmap key newkey [newkey2...] copymap key newkey [newkey2...] copypmap key newkey [newkey2...] @@ -1448,10 +1448,12 @@ example, B<+ar> allows reading for everyone, -ow forbids others to write and See also: man 1 chmod -=item console [-pI<N>] I<command> +=item console [-pI<N> | -s I<sentinel>] I<command> -Opens the console with the command already typed in. The cursor is placed at -I<N>. +Opens the console with the command already typed in. The cursor is placed at +I<N> or at the first occurrence of I<sentinel>. Note that sentinel strings can +potentially occur inside macro expansions. If you cannot provide a sentinel +which is guaranteed to be unique, you should use C<-p>. =item copymap I<key> I<newkey> [I<newkey2> ...] diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 9031e7a2..ea2ab982 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -828,21 +828,32 @@ class mark_tag(Command): class console(Command): - """:console <command> + """:console [-p N | -s sep] <command> + Flags: + -p N Set position at N index + -s sep Set position at separator(any char[s] sequence), example '#' Open the console with the given command. """ def execute(self): position = None + command = "" if self.arg(1)[0:2] == '-p': + command = self.rest(2) try: position = int(self.arg(1)[2:]) except ValueError: pass + elif self.arg(1)[0:2] == '-s': + command = self.rest(3) + separate = self.arg(2) + position = command.find(separate) + if position != -1: + command = command.replace(separate, '', 1) else: - self.shift() - self.fm.open_console(self.rest(1), position=position) + position = None + self.fm.open_console(command, position=position) class load_copy_buffer(Command): |