about summary refs log tree commit diff stats
path: root/059to_text.mu
blob: d45afb0a23012cefeeff36fb2f2cf01a9d741d1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# A couple of variants of 'to-text' that we'll use implicitly in stashes (see
# later layers).
#
# Mu code might specialize them to be smarter, but I don't anticipate any need
# beyond specializing 'to-text' itself.

# 'shorter' variant of to-text, when you want to enable some sort of trimming
# define it to be identical to 'to-text' by default
def to-text-line x:_elem -> y:text [
  local-scope
  load-inputs
  y <- to-text x
]

# variant for arrays (since we can't pass them around otherwise)
def array-to-text-line x:&:@:_elem -> y:text [
  local-scope
  load-inputs
  y <- to-text *x
]

scenario to-text-line-early-warning-for-static-dispatch [
  x:text <- to-text-line 34
  # just ensure there were no errors
]

scenario array-to-text-line-early-warning-for-static-dispatch [
  n:&:@:num <- new number:type, 3
  x:text <- array-to-text-line n
  # just ensure there were no errors
]

# finally, a specialization for single characters
def to-text c:char -> y:text [
  local-scope
  load-inputs
  y <- new character:type, 1/capacity
  *y <- put-index *y, 0, c
]

scenario character-to-text [
  1:char <- copy 111/o
  2:text <- to-text 1:char
  3:@:char <- copy *2:text
  memory-should-contain [
    3:array:character <- [o]
  ]
]
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="$1" shift cd "`$RANGER --cd-after-exit \"$@\" 3>&1 1>&2 2>&3 3>&-`" 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()