about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.pod2
-rw-r--r--ranger/config/rc.conf2
-rw-r--r--ranger/config/rifle.conf1
-rw-r--r--ranger/core/actions.py5
-rw-r--r--ranger/core/fm.py8
-rwxr-xr-xranger/data/scope.sh11
6 files changed, 25 insertions, 4 deletions
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 91ba904a..91629a86 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -228,6 +228,8 @@ The macro %rangerdir expands to the directory of ranger's python library, you
 can use it for something like this command:
   alias show_commands shell less %rangerdir/config/commands.py
 
+%confdir expands to the directory given by B<--confdir>.
+
 The macro %space expands to a space character. You can use it to add spaces to
 the end of a command when needed, while preventing editors to strip spaces off
 the end of the line automatically.
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 43a9b99a..44692d79 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -360,11 +360,13 @@ map dd cut
 map ud uncut
 map da cut mode=add
 map dr cut mode=remove
+map dt cut mode=toggle
 
 map yy copy
 map uy uncut
 map ya copy mode=add
 map yr copy mode=remove
+map yt copy mode=toggle
 
 # Temporary workarounds
 map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier)
diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf
index 31db35a4..f95c94ff 100644
--- a/ranger/config/rifle.conf
+++ b/ranger/config/rifle.conf
@@ -168,6 +168,7 @@ ext djvu, has atril,  X, flag f = atril -- "$@"
 mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
 mime ^image/svg, has display,  X, flag f = display -- "$@"
 
+mime ^image, has pqiv,      X, flag f = pqiv -- "$@"
 mime ^image, has sxiv,      X, flag f = sxiv -- "$@"
 mime ^image, has feh,       X, flag f = feh -- "$@"
 mime ^image, has mirage,    X, flag f = mirage -- "$@"
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index e692eb39..a22b9cd8 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -245,6 +245,7 @@ class Actions(FileManagerAware, SettingsAware):
         macros = {}
 
         macros['rangerdir'] = ranger.RANGERDIR
+        macros['confdir'] = self.fm.confpath()
         macros['space'] = ' '
 
         if self.fm.thisfile:
@@ -1219,7 +1220,7 @@ class Actions(FileManagerAware, SettingsAware):
         Copy the selected items.
         Modes are: 'set', 'add', 'remove'.
         """
-        assert mode in ('set', 'add', 'remove')
+        assert mode in ('set', 'add', 'remove', 'toggle')
         cwd = self.thisdir
         if not narg and not dirarg:
             selected = (f for f in self.thistab.get_selection() if f in cwd.files)
@@ -1241,6 +1242,8 @@ class Actions(FileManagerAware, SettingsAware):
             self.copy_buffer.update(set(selected))
         elif mode == 'remove':
             self.copy_buffer.difference_update(set(selected))
+        elif mode == 'toggle':
+            self.copy_buffer.symmetric_difference_update(set(selected))
         self.do_cut = False
         self.ui.browser.main_column.request_redraw()
 
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 046eb788..f6792b95 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -136,7 +136,7 @@ class FM(Actions, SignalDispatcher):
 
             if self.settings.open_all_images and \
                     len(self.thisdir.marked_items) == 0 and \
-                    re.match(r'^(feh|sxiv|imv) ', command):
+                    re.match(r'^(feh|sxiv|imv|pqiv) ', command):
 
                 images = [f.relative_path for f in self.thisdir.files if f.image]
                 escaped_filenames = " ".join(shell_quote(f) \
@@ -161,6 +161,12 @@ class FM(Actions, SignalDispatcher):
                         new_command = command.replace("imv ",
                                 "imv -n %d " % number, 1)
 
+                    if command[0:5] == 'pqiv ':
+                        number = images.index(self.thisfile.relative_path)
+                        new_command = command.replace("pqiv ",
+                                "pqiv --action \"goto_file_byindex(%d)\" " % \
+                                number, 1)
+
                     if new_command:
                         command = "set -- %s; %s" % (escaped_filenames,
                                 new_command)
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index afaf131f..669d1e34 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -91,8 +91,15 @@ esac
 case "$mimetype" in
     # Syntax highlight for text files:
     text/* | */xml)
-        try safepipe highlight --out-format=ansi "$path" && { dump | trim; exit 5; }
-        try safepipe pygmentize "$path" && { dump | trim; exit 5; }
+        if [ "$(tput colors)" -ge 256 ]; then
+            pygmentize_format=terminal256
+            highlight_format=xterm256
+        else
+            pygmentize_format=terminal
+            highlight_format=ansi
+        fi
+        try safepipe highlight --out-format=${highlight_format} "$path" && { dump | trim; exit 5; }
+        try safepipe pygmentize -f ${pygmentize_format} "$path" && { dump | trim; exit 5; }
         exit 2;;
     # Ascii-previews of images:
     image/*)