## clicking on sandbox results to 'fix' them and turn sandboxes into tests
# todo: perform test from edit/ by faking file system
# clicks on sandbox responses save it as 'expected'
after <global-touch> [
# check if it's inside the output of any sandbox
{
sandbox-left-margin:number <- get *current-sandbox, left:offset
click-column:number <- get *t, column:offset
on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin
break-unless on-sandbox-side?
first-sandbox:address:sandbox-data <- get *env, sandbox:offset
break-unless first-sandbox
first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset
click-row:number <- get *t, row:offset
below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins
break-unless below-sandbox-editor?
# identify the sandbox whose output is being clicked on
sandbox:address:sandbox-data <- find-click-in-sandbox-output env, click-row
break-unless sandbox
# toggle its expected-response, and save session
sandbox <- toggle-expected-response sandbox
save-sandboxes env
hide-screen screen
screen <- render-sandbox-side screen, env, 1/clear
screen <- update-cursor screen, current-sandbox
# no change in cursor
show-screen screen
loop +next-event:label
}
]
recipe find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [
lo#!/usr/bin/python
# coding=utf-8
# ranger: Explore your forest of files from inside your terminal
#
# Copyright (c) 2009, 2010 hut <hut@lavabit.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ----------------------------------------------------------------------------
#
# An embedded shell script. It allows you to change the directory
# of the parent shell to the last visited directory in ranger after exit.
# For more information, check out doc/cd-after-exit.txt
# To enable this, start ranger with:
# source /path/ranger /path/ranger
"""":
if [ $1 ]; then
ranger_exec="$1"
shift
trap "" INT
exec 3< <($ranger_exec --cd-after-exit $@ 3>&1 1>&2 2>&3 3>&-)
while read ranger_output; do false; done <&3
cd "$ranger_output"
exec 3<&-
trap - INT
unset ranger_exec
unset ranger_output
else
echo "usage: source path/to/ranger.py path/to/ranger.py"
fi
return 1
"""
# Redefine the docstring, since the previous one was hijacked to
# embed a shellscript.
__doc__ = """Ranger - file browser for the unix terminal"""
# Importing the main method may fail if the ranger directory
# is neither in the same directory as this file, nor in one of
# pythons global import paths.
try:
from ranger import main
except ImportError as errormessage:
if str(errormessage).endswith("main"):
print("Can't import the main module.")
print("To run an uninstalled copy of ranger,")
print("launch ranger.py in the top directory.")
else:
raise
else:
main()