summary refs log blame commit diff stats
path: root/ranger.py
blob: fbceab23308efdce6c201c3ea65252189e6279ce (plain) (tree)
cba63cf3 pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.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 */
-- helpers for selecting portions of text

local utf8 = require 'utf8'

-- Return any intersection of the region from Selection1 to Cursor1 (or
-- current mouse, if mouse is pressed; or recent mouse if mouse is pressed and
-- currently over a drawing) with the region between {line=line_index, pos=apos}
-- and {line=line_index, pos=bpos}.
-- apos must be less than bpos. However Selection1 and Cursor1 can be in any order.
-- Result: positions spos,epos between apos,bpos.
function Text.clip_selection(line_index, apos, bpos)
  if Selection1.line == nil then return nil,nil end
  -- min,max = sorted(Selection1,Cursor1)
  local minl,minp = Selection1.line,Selection1.pos
  local maxl,maxp
  if love.mouse.isDown('1') then
    maxl,maxp = Text.mouse_pos()
  else
    maxl,maxp = Cursor1.line,Cursor1.pos
  end
  if minl > maxl then
    minl,maxl = maxl,minl
    minp,maxp = maxp,minp
  elseif minl == maxl then
    if minp > maxp then
      minp,maxp = maxp,minp
    end
  end
  -- check if intervals are disjoint
  if line_index < minl then return nil,nil end
  if line_index > maxl then retu
#!/usr/bin/python -O
# coding=utf-8
#
# Ranger: Explore your forest of files from inside your terminal
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Embed a script which allows you to change the directory of the parent shell
# after you exit ranger.  Run it with the command: source ranger ranger
"""":
if [ $1 ]; then
	$@ --fail-unless-cd &&
	if [ -z "$XDG_CONFIG_HOME" ]; then
		cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
	else
		cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
	fi && return 0
else
	echo "usage: source path/to/ranger.py path/to/ranger.py"
fi
return 1
"""

import sys

# When using the --clean option, not even bytecode should be written.
# Need to find out if --clean is used as soon as possible.
try:
	argv = sys.argv[0:sys.argv.index('--')]
except:
	argv = sys.argv
sys.dont_write_bytecode = '-c' in argv or '--clean' in argv

# Set the actual docstring
__doc__ = """Ranger - file browser for the unix terminal"""

# Start ranger
import ranger
sys.exit(ranger.main())
ass="p">.mouse_pos() local time = love.timer.getTime() if Recent_mouse.time and Recent_mouse.time > time-0.1 then return Recent_mouse.line, Recent_mouse.pos end Recent_mouse.time = time local line,pos = Text.to_pos(love.mouse.getX(), love.mouse.getY()) if line then Recent_mouse.line = line Recent_mouse.pos = pos end return Recent_mouse.line, Recent_mouse.pos end function Text.to_pos(x,y) for line_index,line in ipairs(Lines) do if line.mode == 'text' then if Text.in_line(line, x,y) then return line_index, Text.to_pos_on_line(line, x,y) end end end end function Text.delete_selection() local minl,maxl = minmax(Selection1.line, Cursor1.line) local before = snapshot(minl, maxl) Text.delete_selection_without_undo() record_undo_event({before=before, after=snapshot(Cursor1.line)}) end function Text.delete_selection_without_undo() if Selection1.line == nil then return end -- min,max = sorted(Selection1,Cursor1) local minl,minp = Selection1.line,Selection1.pos local maxl,maxp = Cursor1.line,Cursor1.pos if minl > maxl then minl,maxl = maxl,minl minp,maxp = maxp,minp elseif minl == maxl then if minp > maxp then minp,maxp = maxp,minp end end -- update Cursor1 and Selection1 Cursor1.line = minl Cursor1.pos = minp Selection1 = {} -- delete everything between min (inclusive) and max (exclusive) Lines[minl].fragments = nil Lines[minl].screen_line_starting_pos = nil local min_offset = utf8.offset(Lines[minl].data, minp) local max_offset = utf8.offset(Lines[maxl].data, maxp) if minl == maxl then --? print('minl == maxl') Lines[minl].data = Lines[minl].data:sub(1, min_offset-1)..Lines[minl].data:sub(max_offset) return end assert(minl < maxl) local rhs = Lines[maxl].data:sub(max_offset) for i=maxl,minl+1,-1 do table.remove(Lines, i) end Lines[minl].data = Lines[minl].data:sub(1, min_offset-1)..rhs end function Text.selection() if Selection1.line == nil then return end -- min,max = sorted(Selection1,Cursor1) local minl,minp = Selection1.line,Selection1.pos local maxl,maxp = Cursor1.line,Cursor1.pos if minl > maxl then minl,maxl = maxl,minl minp,maxp = maxp,minp elseif minl == maxl then if minp > maxp then minp,maxp = maxp,minp end end local min_offset = utf8.offset(Lines[minl].data, minp) local max_offset = utf8.offset(Lines[maxl].data, maxp) if minl == maxl then return Lines[minl].data:sub(min_offset, max_offset-1) end assert(minl < maxl) local result = Lines[minl].data:sub(min_offset)..'\n' for i=minl+1,maxl-1 do if Lines[i].mode == 'text' then result = result..Lines[i].data..'\n' end end result = result..Lines[maxl].data:sub(1, max_offset-1) return result end function Text.cut_selection() local result = Text.selection() Text.delete_selection() return result end