about summary refs log tree commit diff stats
path: root/507line.mu
blob: fadd66394cc78a89202b25092dbef3faee07ee12 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
fn draw-line screen: (addr screen), x0: int, y0: int, x1: int, y1: int, color: int {
  var dx: int
  var dy: int
  var sx: int
  var sy: int
  var err: int
  # dx = abs(x1-x0)
  var tmp2/ecx: int <- copy x1
  tmp2 <- subtract x0
  var tmp/eax: int <- abs tmp2
  copy-to dx, tmp
  # sx = sgn(x1-x0)
  tmp <- sgn tmp2
  copy-to sx, tmp
  # dy = -abs(y1-y0)
  tmp2 <- copy y1
  tmp2 <- subtract y0
  tmp <- abs tmp2
  tmp <- negate
  copy-to dy, tmp
  # sy = sgn(y1-y0)
  tmp <- sgn tmp2
  copy-to sy, tmp
  # err = dx + dy
  tmp <- copy dy
  tmp <- add dx
  copy-to err, tmp
  #
  var x/ecx: int <- copy x0
  var y/edx: int <- copy y0
  $draw-line:loop: {
    pixel screen, x, y, color
    # if (x == x1 && y == y1) break
    {
      compare x, x1
      break-if-!=
      compare y, y1
      break-if-!=
      break $draw-line:loop
    }
    # e2 = err*2
    var e2/ebx: int <- copy err
    e2 <- shift-left 1
    # if (e2 >= dy) { err += dy; x += sx; }
    {
      compare e2, dy
      break-if-<
      tmp <- copy dy
      add-to err, tmp
      x <- add sx
    }
    # if (e2 <= dx) { err += dx; y += sy; }
    {
      compare e2, dx
      break-if->
      tmp <- copy dx
      add-to err, tmp
      y <- add sy
    }
    loop
  }
}

fn draw-horizontal-line screen: (addr screen), y: int, x0: int, x1: int, color: int {
  var x/eax: int <- copy x0
  {
    compare x, x1
    break-if->=
    pixel screen, x, y, color
    x <- increment
    loop
  }
}

fn draw-vertical-line screen: (addr screen), x: int, y0: int, y1: int, color: int {
  var y/eax: int <- copy y0
  {
    compare y, y1
    break-if->=
    pixel screen, x, y, color
    y <- increment
    loop
  }
}

fn draw-rect screen: (addr screen), xmin: int, ymin: int, xmax: int, ymax: int, color: int {
  var y/eax: int <- copy ymin
  {
    compare y, ymax
    break-if->=
    draw-horizontal-line screen, y, xmin, xmax, color
    y <- increment
    loop
  }
}

# 0 <= u <= 1
fn line-point u: float, x0: int, x1: int -> _/eax: int {
  var one/eax: int <- copy 1
  var u-prime/xmm0: float <- convert one
  u-prime <- subtract u
  var result/xmm1: float <- convert x0
  result <- multiply u-prime
  var term2/xmm2: float <- convert x1
  term2 <- multiply u
  result <- add term2
  var result/eax: int <- convert result
  return result
}
d by default, and \fIcommand\fR is the command that is going to be executed. .IP "\fB\-p\fR \fI\s-1KEYWORD\s0\fR" 14 .IX Item "-p KEYWORD" Pick a method to open the files. .Sp \&\fI\s-1KEYWORD\s0\fR is either the \s-1ID\s0 number listed by \f(CW\*(C`rifle \-l\*(C'\fR or a string that matches a label in the configuration file. .IP "\fB\-w\fR \fI\s-1PROGRAM\s0\fR" 14 .IX Item "-w PROGRAM" Open the files with the program \fI\s-1PROGRAM\s0\fR .IP "\fB\-h\fR, \fB\-\-help\fR" 14 .IX Item "-h, --help" Print a list of options and exit. .SH "FILES" .IX Header "FILES" rifle shares configuration files with ranger, though ranger is not required in order to use rifle. The configuration file \fIrifle.conf\fR is expected to be at \&\fI~/.config/ranger/rifle.conf\fR. .PP This file specifies patterns for determining the commands to open files with. The syntax is described in the comments of the default \fIrifle.conf\fR that ships with ranger. To obtain it, you need to run: \f(CW\*(C`ranger \-\-copy\-config=rifle\*(C'\fR .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .IP "\s-1EDITOR\s0" 8 .IX Item "EDITOR" Determines which editor to use for editing files (in the default \fIrifle.conf\fR). .IP "\s-1PAGER\s0" 8 .IX Item "PAGER" Determines which pager to use for displaying files (in the default \fIrifle.conf\fR). .IP "\s-1TERMCMD\s0" 8 .IX Item "TERMCMD" Determines the terminal emulator command for use with the \fIt\fR flag. It is required that the value is the path to an executable file which accepts the \*(L"\-e \s-1COMMAND\s0\*(R" argument. .IP "\s-1XDG_CONFIG_HOME\s0" 8 .IX Item "XDG_CONFIG_HOME" Specifies the directory for configuration files. Defaults to \fI\f(CI$HOME\fI/.config\fR. .SH "EXAMPLES" .IX Header "EXAMPLES" List all the different methods: .PP .Vb 4 \& $ rifle \-l helloworld.py \& 0:editor::"$EDITOR" \-\- "$@" \& 1:pager::"$PAGER" \-\- "$@" \& 2:::python \-\- "$1" .Ve .PP Display its content by opening it with \*(L"cat\*(R": .PP .Vb 2 \& $ rifle \-w cat helloworld.py \& print("Hello World!") .Ve .PP Run it by picking the method 2, which calls 'python \*(-- \*(L"$1\*(R"': .PP .Vb 2 \& $ rifle \-p 2 helloworld.py \& Hello World! .Ve .PP Display the file in a pager inside a new terminal, run as root: .PP .Vb 1 \& $ rifle \-p 1 \-f tr helloworld.py .Ve