summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-25 05:00:36 +0100
committerhut <hut@lavabit.com>2013-02-25 05:00:36 +0100
commita573bda31bcd172454b5ec79c6f8ae384ab900bc (patch)
tree5a505a8f5757548681eef37d9fd86b9a01768861 /ranger
parent15f811477ce6d46c1a422c9fd58d977035ff9dfd (diff)
downloadranger-a573bda31bcd172454b5ec79c6f8ae384ab900bc.tar.gz
commands.scout: added UNMARK, SMART_CASE, use set_search_method
Diffstat (limited to 'ranger')
-rw-r--r--ranger/config/commands.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 367a4a0b..c267dcf3 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1049,7 +1049,9 @@ class scout(Command):
     KEEP_OPEN       = 'k'
     SM_LETTERSKIP   = 'l'
     MARK            = 'm'
+    UNMARK          = 'M'
     SM_REGEX        = 'r'
+    SMART_CASE      = 's'
     AS_YOU_TYPE     = 't'
     INVERT          = 'v'
 
@@ -1062,17 +1064,21 @@ class scout(Command):
         thisdir = self.fm.thisdir
         flags   = self.flags
         pattern = self.pattern
+        regex   = self._build_regex()
         count   = self._count(move=True)
 
-        if self.MARK in flags:
+        self.fm.thistab.last_search = regex
+        self.fm.set_search_method(order="search")
+
+        if self.MARK in flags or self.UNMARK in flags:
+            value = flags.find(self.MARK) > flags.find(self.UNMARK)
             if self.FILTER in flags:
                 for f in thisdir.files:
-                    thisdir.mark_item(f, True)
+                    thisdir.mark_item(f, value)
             else:
-                regex = self._build_regex()
                 for f in thisdir.files:
                     if regex.search(f.basename):
-                        thisdir.mark_item(f, True)
+                        thisdir.mark_item(f, value)
 
         # clean up:
         self.cancel()
@@ -1143,7 +1149,10 @@ class scout(Command):
             regex = "^(?:(?!%s).)*$" % regex
 
         # Compile Regular Expression
-        options = re.I if self.IGNORE_CASE in flags else 0
+        options = re.LOCALE | re.UNICODE
+        if self.IGNORE_CASE in flags or self.SMART_CASE in flags and \
+                pattern.islower():
+            options |= re.IGNORECASE
         try:
             self._regex = re.compile(regex, options)
         except:
l.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
fn draw-circle screen: (addr screen), cx: int, cy: int, radius: int, color: int {
  var x: int
  var y: int
  var err: int
  # x = -r
  var tmp/eax: int <- copy radius
  tmp <- negate
  copy-to x, tmp
  # err = 2 - 2*r
  tmp <- copy radius
  tmp <- shift-left 1
  tmp <- negate
  tmp <- add 2
  copy-to err, tmp
  #
  var tmpx/ecx: int <- copy 0
  var tmpy/edx: int <- copy 0
  {
    # pixel(cx-x, cy+y)
    tmpx <- copy cx
    tmpx <- subtract x
    tmpy <- copy cy
    tmpy <- add y
    pixel screen, tmpx, tmpy, color
    # pixel(cx-y, cy-x)
    tmpx <- copy cx
    tmpx <- subtract y
    tmpy <- copy cy
    tmpy <- subtract x
    pixel screen, tmpx, tmpy, color
    # pixel(cx+x, cy-y)
    tmpx <- copy cx
    tmpx <- add x
    tmpy <- copy cy
    tmpy <- subtract y
    pixel screen, tmpx, tmpy, color
    # pixel(cx+y, cy+x)
    tmpx <- copy cx
    tmpx <- add y
    tmpy <- copy cy
    tmpy <- add x
    pixel screen, tmpx, tmpy, color
    # r = err
    tmp <- copy err
    copy-to radius, tmp
    # if (r <= y) { ++y; err += (y*2 + 1); }
    {
      tmpy <- copy y
      compare radius, tmpy
      break-if->
      increment y
      tmpy <- copy y
      tmpy <- shift-left 1
      tmpy <- increment
      add-to err, tmpy
    }
    # if (r > x || err > y) { ++x; err += (x*2 + 1); }
    $draw-circle:second-check: {
      {
        tmpx <- copy x
        compare radius, tmpx
        break-if->
        tmpy <- copy y
        compare err, tmpy
        break-if->
        break $draw-circle:second-check
      }
      increment x
      tmpx <- copy x
      tmpx <- shift-left 1
      tmpx <- increment
      add-to err, tmpx
    }
    # loop termination condition
    compare x, 0
    loop-if-<
  }
}

fn draw-disc screen: (addr screen), cx: int, cy: int, radius: int, color: int, border-color: int {
  var r/eax: int <- copy 0
  {
    compare r, radius
    break-if->=
    draw-circle screen, cx cy, r, color
    r <- increment
    loop
  }
  draw-circle screen, cx cy, r, border-color
}