about summary refs log tree commit diff stats
path: root/doc/ranger.1
Commit message (Expand)AuthorAgeFilesLines
* settingobject: remove complexity of shorten_title settinghut2013-03-011-3/+3
* doc/ranger.1: removed obsolete reference to fm.envhut2013-03-011-1/+1
* doc/ranger.1: documented :scout commandhut2013-03-011-1/+26
* doc/ranger.1: Fixed --copy-config documentationhut2013-02-281-2/+2
* Merge branch 'vcs'hut2013-02-241-0/+12
|\
| * Merge branch 'master' into vcshut2013-02-221-44/+51
| |\
| * \ Merge branch 'master' into vcshut2013-02-191-0/+3
| |\ \
| * \ \ Merge branch 'master' into vcshut2013-02-181-41/+47
| |\ \ \
| * | | | document config options for vcs on the man pageAbdo Roig-Maranges2013-02-171-5/+10
| * | | | Rebuilt manpageAbdo Roig-Maranges2013-02-121-1/+8
* | | | | Fire in the Hole! v1.6.0hut2013-02-221-1/+1
| |_|_|/ |/| | |
* | | | core.main: added RANGER_LOAD_DEFAULT_RC environment variablehut2013-02-221-0/+5
* | | | doc/ranger.1: update ENVIRONMENT sectionhut2013-02-221-4/+2
* | | | doc/ranger.1: typohut2013-02-221-1/+1
* | | | doc/ranger.1: added chmod key bindings to man pagehut2013-02-221-0/+4
* | | | doc/ranger.1: remove midnight commander bindings from man pagehut2013-02-221-26/+0
* | | | doc/ranger.1: update KEY BINDINGS sectionhut2013-02-221-11/+25
* | | | doc/ranger.1: updated the CONCEPTS sectionhut2013-02-221-2/+14
| |_|/ |/| |
* | | doc/rifle.1: added whitespace at exampleshut2013-02-181-0/+3
| |/ |/|
* | README: removed bash dependencyhut2013-02-181-1/+1
* | ranger.1: update list of ranger optionshut2013-02-181-8/+17
* | ranger.1: added missing docs of settingshut2013-02-181-1/+8
* | ranger.__init__: change [path/filename] to [path] in USAGEhut2013-02-181-1/+1
* | ranger.1: update doc of :open_withhut2013-02-181-3/+2
* | doc/ranger.1: update doc of :chmod, :delete, :find, :save_copy_bufferhut2013-02-181-14/+11
* | doc/ranger.1: fully removed --mode and --flags from man pagehut2013-02-171-9/+0
* | doc/ranger.1: added :travel to man pagehut2013-02-171-0/+8
* | core.main: made --mode and --flag deprecatedhut2013-02-171-2/+1
* | core.main: made --fail-unless-cd deprecatedhut2013-02-171-6/+2
|/
* config/commands: Added commands 'mark_tag' and 'unmark_tag'hut2013-01-011-1/+11
* container.settingobject: added setting "update_tmux_title"hut2012-12-101-1/+4
* added setlocal command to handle local settingsAbdó Roig-Maranges2012-12-091-2/+8
* config/rc.conf: Added setting "confirm_on_delete"hut2012-12-061-1/+6
* doc/ranger.1: typohut2012-12-041-1/+1
* doc/ranger.1: add a warning about overwriting hookshut2012-12-041-2/+5
* updated man page, improved hookshut2012-12-041-39/+78
* update documentation for commandshut2012-12-041-25/+80
* update documentation for options, plugins and exampleshut2012-12-041-88/+67
* Merge branch 'stable'hut2012-08-101-1/+1
|\
| * ceci n'est pas un nouveau version v1.5.5hut2012-08-101-2/+2
* | doc/ranger.1: rebuilt man pagehut2012-08-021-5/+5
|/
* What kind of idiot invented bugs anyway? v1.5.4hut2012-05-031-2/+2
* Always remember to bring your towel. v1.5.3hut2012-03-051-1/+1
* Added $RANGER_LEVEL environment variable (see man page)hut2012-03-051-0/+13
* Removed unnecessary spaceshut2012-03-051-2/+2
* ranger.1: fix vim script "RangerChooser" when no file is openedhut2012-02-211-2/+2
* ranger.1: Added entry for --list-tagged-fileshut2012-02-121-0/+4
* core.main: Allow multiple --cmd's, add man page entry for --cmdhut2012-02-121-1/+5
* new :relink commandM Rawash2012-01-271-0/+8
* Added documentation for new flagsM Rawash2011-12-111-1/+6
eral.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.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 */
# A doubly linked list permits bidirectional traversal.

container duplex-list:_elem [
  value:_elem
  next:&:duplex-list:_elem
  prev:&:duplex-list:_elem
]

# should I say in/contained-in:result, allow ingredients to refer to products?
def push x:_elem, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
  local-scope
  load-ingredients
  result:&:duplex-list:_elem <- new {(duplex-list _elem): type}
  *result <- merge x, in, 0
  {
    break-unless in
    *in <- put *in, prev:offset, result
  }
  return result  # needed explicitly because we need to replace 'in' with 'result'
]

def first in:&:duplex-list:_elem -> result:_elem [
  local-scope
  load-ingredients
  return-unless in, 0
  result <- get *in, value:offset
]

def next in:&:duplex-list:_elem -> result:&:duplex-list:_elem/contained-in:in [
  local-scope
  load-ingredients
  return-unless in, 0
  result <- get *in, next:offset
]

def prev in:&:duplex-list:_elem -> result:&:duplex-list:_elem/contained-in:in [
  local-scope
  load-ingredients
  return-unless in, 0
  result <- get *in, prev:offset
  return result
]

scenario duplex-list-handling [
  run [
    local-scope
    # reserve locations 0-9 to check for missing null check
    10:num/raw <- copy 34
    11:num/raw <- copy 35
    list:&:duplex-list:char <- push 3, 0
    list <- push 4, list
    list <- push 5, list
    list2:&:duplex-list:char <- copy list
    20:char/raw <- first list2
    list2 <- next list2
    21:char/raw <- first list2
    list2 <- next list2
    22:char/raw <- first list2
    30:&:duplex-list:char/raw <- next list2
    31:char/raw <- first 30:&:duplex-list:char/raw
    32:&:duplex-list:char/raw <- next 30:&:duplex-list:char/raw
    33:&:duplex-list:char/raw <- prev 30:&:duplex-list:char/raw
    list2 <- prev list2
    40:char/raw <- first list2
    list2 <- prev list2
    41:char/raw <- first list2
    50:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    0 <- 0  # no modifications to null pointers
    10 <- 34
    11 <- 35
    20 <- 5  # scanning next
    21 <- 4
    22 <- 3
    30 <- 0  # null
    31 <- 0  # first of null
    32 <- 0  # next of null
    33 <- 0  # prev of null
    40 <- 4  # then start scanning prev
    41 <- 5
    50 <- 1  # list back at start
  ]
]

# insert 'x' after 'in'
def insert x:_elem, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
  local-scope
  load-ingredients
  new-node:&:duplex-list:_elem <- new {(duplex-list _elem): type}
  *new-node <- put *new-node, value:offset, x
  # save old next before changing it
  next-node:&:duplex-list:_elem <- get *in, next:offset
  *in <- put *in, next:offset, new-node
  *new-node <- put *new-node, prev:offset, in
  *new-node <- put *new-node, next:offset, next-node
  return-unless next-node
  *next-node <- put *next-node, prev:offset, new-node
]

scenario inserting-into-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  list <- push 4, list
  list <- push 5, list
  run [
    list2:&:duplex-list:char <- next list  # inside list
    list2 <- insert 6, list2
    # check structure like before
    list2 <- copy list
    10:char/raw <- first list2
    list2 <- next list2
    11:char/raw <- first list2
    list2 <- next list2
    12:char/raw <- first list2
    list2 <- next list2
    13:char/raw <- first list2
    list2 <- prev list2
    20:char/raw <- first list2
    list2 <- prev list2
    21:char/raw <- first list2
    list2 <- prev list2
    22:char/raw <- first list2
    30:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    10 <- 5  # scanning next
    11 <- 4
    12 <- 6  # inserted element
    13 <- 3
    20 <- 6  # then prev
    21 <- 4
    22 <- 5
    30 <- 1  # list back at start
  ]
]

scenario inserting-at-end-of-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  list <- push 4, list
  list <- push 5, list
  run [
    list2:&:duplex-list:char <- next list  # inside list
    list2 <- next list2  # now at end of list
    list2 <- insert 6, list2
    # check structure like before
    list2 <- copy list
    10:char/raw <- first list2
    list2 <- next list2
    11:char/raw <- first list2
    list2 <- next list2
    12:char/raw <- first list2
    list2 <- next list2
    13:char/raw <- first list2
    list2 <- prev list2
    20:char/raw <- first list2
    list2 <- prev list2
    21:char/raw <- first list2
    list2 <- prev list2
    22:char/raw <- first list2
    30:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    10 <- 5  # scanning next
    11 <- 4
    12 <- 3
    13 <- 6  # inserted element
    20 <- 3  # then prev
    21 <- 4
    22 <- 5
    30 <- 1  # list back at start
  ]
]

scenario inserting-after-start-of-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  list <- push 4, list
  list <- push 5, list
  run [
    list <- insert 6, list
    # check structure like before
    list2:&:duplex-list:char <- copy list
    10:char/raw <- first list2
    list2 <- next list2
    11:char/raw <- first list2
    list2 <- next list2
    12:char/raw <- first list2
    list2 <- next list2
    13:char/raw <- first list2
    list2 <- prev list2
    20:char/raw <- first list2
    list2 <- prev list2
    21:char/raw <- first list2
    list2 <- prev list2
    22:char/raw <- first list2
    30:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    10 <- 5  # scanning next
    11 <- 6  # inserted element
    12 <- 4
    13 <- 3
    20 <- 4  # then prev
    21 <- 6
    22 <- 5
    30 <- 1  # list back at start
  ]
]

# remove 'x' from its surrounding list 'in'
#
# Returns null if and only if list is empty. Beware: in that case any other
# pointers to the head are now invalid.
def remove x:&:duplex-list:_elem/contained-in:in, in:&:duplex-list:_elem -> in:&:duplex-list:_elem [
  local-scope
  load-ingredients
  # if 'x' is null, return
  return-unless x
  next-node:&:duplex-list:_elem <- get *x, next:offset
  prev-node:&:duplex-list:_elem <- get *x, prev:offset
  # null x's pointers
  *x <- put *x, next:offset, 0
  *x <- put *x, prev:offset, 0
  # if next-node is not null, set its prev pointer
  {
    break-unless next-node
    *next-node <- put *next-node, prev:offset, prev-node
  }
  # if prev-node is not null, set its next pointer and return
  {
    break-unless prev-node
    *prev-node <- put *prev-node, next:offset, next-node
    return
  }
  # if prev-node is null, then we removed the head node at 'in'
  # return the new head rather than the old 'in'
  return next-node
]

scenario removing-from-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  list <- push 4, list
  list <- push 5, list
  run [
    list2:&:duplex-list:char <- next list  # second element
    list <- remove list2, list
    10:bool/raw <- equal list2, 0
    # check structure like before
    list2 <- copy list
    11:char/raw <- first list2
    list2 <- next list2
    12:char/raw <- first list2
    20:&:duplex-list:char/raw <- next list2
    list2 <- prev list2
    30:char/raw <- first list2
    40:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    10 <- 0  # remove returned non-null
    11 <- 5  # scanning next, skipping deleted element
    12 <- 3
    20 <- 0  # no more elements
    30 <- 5  # prev of final element
    40 <- 1  # list back at start
  ]
]

scenario removing-from-start-of-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  list <- push 4, list
  list <- push 5, list
  run [
    list <- remove list, list
    # check structure like before
    list2:&:duplex-list:char <- copy list
    10:char/raw <- first list2
    list2 <- next list2
    11:char/raw <- first list2
    20:&:duplex-list:char/raw <- next list2
    list2 <- prev list2
    30:char/raw <- first list2
    40:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    10 <- 4  # scanning next, skipping deleted element
    11 <- 3
    20 <- 0  # no more elements
    30 <- 4  # prev of final element
    40 <- 1  # list back at start
  ]
]

scenario removing-from-end-of-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  list <- push 4, list
  list <- push 5, list
  run [
    # delete last element
    list2:&:duplex-list:char <- next list
    list2 <- next list2
    list <- remove list2, list
    10:bool/raw <- equal list2, 0
    # check structure like before
    list2 <- copy list
    11:char/raw <- first list2
    list2 <- next list2
    12:char/raw <- first list2
    20:&:duplex-list:char/raw <- next list2
    list2 <- prev list2
    30:char/raw <- first list2
    40:bool/raw <- equal list, list2
  ]
  memory-should-contain [
    10 <- 0  # remove returned non-null
    11 <- 5  # scanning next, skipping deleted element
    12 <- 4
    20 <- 0  # no more elements
    30 <- 5  # prev of final element
    40 <- 1  # list back at start
  ]
]

scenario removing-from-singleton-duplex-list [
  local-scope
  list:&:duplex-list:char <- push 3, 0
  run [
    list <- remove list, list
    1:num/raw <- copy list
  ]
  memory-should-contain [
    1 <- 0  # back to an empty list
  ]
]

# remove values between 'start' and 'end' (both exclusive).
# also clear pointers back out from start/end for hygiene.
# set end to 0 to delete everything past start.
# can't set start to 0 to delete everything before end, because there's no
# clean way to return the new head pointer.
def remove-between start:&:duplex-list:_elem, end:&:duplex-list:_elem/contained-in:start -> start:&:duplex-list:_elem [
  local-scope
  load-ingredients
  next:&:duplex-list:_elem <- get *start, next:offset
  nothing-to-delete?:bool <- equal next, end
  return-if nothing-to-delete?
  assert next, [malformed duplex list]
  # start->next->prev = 0
  # start->next = end
  *next <- put *next, prev:offset, 0
  *start <- put *start, next:offset, end
  return-unless end
  # end->prev->next = 0
  # end->prev = start
  prev:&:duplex-list:_elem <- get *end, prev:offset
  assert prev, [malformed duplex list - 2]
  *prev <- put *prev, next:offset, 0
  *end <- put *end, prev:offset, start
]

scenario remove-range [
  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
  local-scope
  list:&:duplex-list:char <- push 18, 0
  list <- push 17, list
  list <- push 16, list
  list <- push 15, list
  list <- push 14, list
  list <- push 13, list
  run [
    # delete 16 onwards
    # first pointer: to the third element
    list2:&:duplex-list:char <- next list
    list2 <- next list2
    list2 <- remove-between list2, 0
    # now check the list
    10:char/raw <- get *list, value:offset
    list <- next list
    11:char/raw <- get *list, value:offset
    list <- next list
    12:char/raw <- get *list, value:offset
    20:&:duplex-list:char/raw <- next list
  ]
  memory-should-contain [
    10 <- 13
    11 <- 14
    12 <- 15
    20 <- 0
  ]
]

scenario remove-range-to-final [
  local-scope
  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
  list:&:duplex-list:char <- push 18, 0
  list <- push 17, list
  list <- push 16, list
  list <- push 15, list
  list <- push 14, list
  list <- push 13, list
  run [
    # delete 15, 16 and 17
    # start pointer: to the second element
    list2:&:duplex-list:char <- next list
    # end pointer: to the last (sixth) element
    end:&:duplex-list:char <- next list2
    end <- next end
    end <- next end
    end <- next end
    remove-between list2, end
    # now check the list
    10:char/raw <- get *list, value:offset
    list <- next list
    11:char/raw <- get *list, value:offset
    list <- next list
    12:char/raw <- get *list, value:offset
    20:&:duplex-list:char/raw <- next list
  ]
  memory-should-contain [
    10 <- 13
    11 <- 14
    12 <- 18
    20 <- 0  # no more elements
  ]
]

scenario remove-range-empty [
  local-scope
  # construct a duplex list with three elements [13, 14, 15]
  list:&:duplex-list:char <- push 15, 0
  list <- push 14, list
  list <- push 13, list
  run [
    # delete between first and second element (i.e. nothing)
    list2:&:duplex-list:char <- next list
    remove-between list, list2
    # now check the list
    10:char/raw <- get *list, value:offset
    list <- next list
    11:char/raw <- get *list, value:offset
    list <- next list
    12:char/raw <- get *list, value:offset
    20:&:duplex-list:char/raw <- next list
  ]
  # no change
  memory-should-contain [
    10 <- 13
    11 <- 14
    12 <- 15
    20 <- 0
  ]
]

scenario remove-range-to-end [
  local-scope
  # construct a duplex list with six elements [13, 14, 15, 16, 17, 18]
  list:&:duplex-list:char <- push 18, 0
  list <- push 17, list
  list <- push 16, list
  list <- push 15, list
  list <- push 14, list
  list <- push 13, list
  run [
    # remove the third element and beyond
    list2:&:duplex-list:char <- next list
    remove-between list2, 0
    # now check the list
    10:char/raw <- get *list, value:offset
    list <- next list
    11:char/raw <- get *list, value:offset
    20:&:duplex-list:char/raw <- next list
  ]
  memory-should-contain [
    10 <- 13
    11 <- 14
    20 <- 0
  ]
]

# insert list beginning at 'new' after 'in'
def insert-range in:&:duplex-list:_elem, start:&:duplex-list:_elem/contained-in:in -> in:&:duplex-list:_elem [
  local-scope
  load-ingredients
  return-unless in
  return-unless start
  end:&:duplex-list:_elem <- copy start
  {
    next:&:duplex-list:_elem <- next end/insert-range
    break-unless next
    end <- copy next
    loop
  }
  next:&:duplex-list:_elem <- next in
  *end <- put *end, next:offset, next
  {
    break-unless next
    *next <- put *next, prev:offset, end
  }
  *in <- put *in, next:offset, start
  *start <- put *start, prev:offset, in
]

def append in:&:duplex-list:_elem, new:&:duplex-list:_elem/contained-in:in -> in:&:duplex-list:_elem [
  local-scope
  load-ingredients
  last:&:duplex-list:_elem <- last in
  *last <- put *last, next:offset, new
  return-unless new
  *new <- put *new, prev:offset, last
]

def last in:&:duplex-list:_elem -> result:&:duplex-list:_elem [
  local-scope
  load-ingredients
  result <- copy in
  {
    next:&:duplex-list:_elem <- next result
    break-unless next
    result <- copy next
    loop
  }
]

# helper for debugging
def dump-from x:&:duplex-list:_elem [
  local-scope
  load-ingredients
  $print x, [: ]
  {
    break-unless x
    c:_elem <- get *x, value:offset
    $print c, [ ]
    x <- next x
    {
      is-newline?:bool <- equal c, 10/newline
      break-unless is-newline?
      $print 10/newline
      $print x, [: ]
    }
    loop
  }
  $print 10/newline, [---], 10/newline
]