-
Notifications
You must be signed in to change notification settings - Fork 1
/
headline.fs
126 lines (105 loc) · 3.67 KB
/
headline.fs
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
\ galope/headline.fs
\ This file is part of Galope
\ http:https://programandala.net/en.program.galope.html
\ Author: Marcos Cruz (programandala.net), 2012, 2013, 2014, 2017.
\ ==============================================================
\ XXX TODO -- finish
\ XXX TODO -- update the stack notation
\ ==============================================================
require module.fs
require xy.fs
package galope-headline
variable y variable x \ top left coordinates
variable heigth \ rows of the headline
variable width \ max width that can be shown
: +row? ( u -- f )
heigth @ 1- <
;
: (+row) cr x @ at-x
;
: +row ( u -- )
+row? if (+row) then
;
: row/ ( a1 u1 -- a1 u1 | a1 u2 )
width @ min
;
: .row ( a1 u1 u2 -- )
>r row/ type r> +row
;
: (.headline) ( a u ... a' u' n -- )
0 do i .row loop
;
: init ( u -- )
heigth ! cols column dup x ! - width !
;
public
: .headline ( a1 u1 ... an un n -- )
\ Print a headline at the current cursor position.
\ n = headline rows
dup init 2rolls heigth @ (.headline)
;
\ ----8<------------------------
\ Unfinished addon!!!
: (.banner) ( xt u -- )
y @ at-xy execute .headline
;
: .banner ( xt -- )
row y !
dup 0 cols 1- do dup i (.banner) -1 +loop drop
;
\ ----8<------------------------
\ ----8<------------------------
false [if] \ Unfinished alternative!!!
: headline" ( -- )
postpone s"
; immediate
: headline: ( "name" -- )
here create 2 cells allot
;
: ;headline ( a -- )
;
[then]
\ ----8<------------------------
\ Testing
: epic ( -- a0 u0 ... a7 u7 8 )
s" _______ _______ _______ _ ________________ _______ _______ _________________________ _______ _______"
s" ( ___ ) ____ \ ___ ) \ \__ __/ ___ ) |\ /| ( ____ \ ___ ) ____ \__ __/\__ __/( ____ \ ___ )"
s" | ( ) | ( \/ ( ) | ( ) ( | ( ) | ( \ / ) | ( \/ ( ) | ( \/ ) ( ) ( | ( \/ ( ) |"
s" | (___) | (_____| (___) | | | | | | | | \ (_) / | | | (___) | (_____ | | | | | | | | | |"
s" | ___ |_____ ) ___ | | | | | | | | \ / | | | ___ |_____ ) | | | | | | ____| | | |"
s" | ( ) | ) | ( ) | | | | | | | | ) ( | | | ( ) | ) | | | | | | | \_ ) | | |"
s" | ) ( |\____) | ) ( | (____/\ | | (___) | | | | (____/\ ) ( |\____) | | | ___) (___| (___) | (___) |"
s" |/ \|_______)/ \|_______/_( (_______) \_/ (_______// \|_______) )_( \_______/(_______)_______)"
8 \ lines
;
: ogre ( -- a0 u0 ... a5 u5 6 )
s" _ _ _ _ _"
s" /_\ ___ __ _| | |_ ___ _ _ ___ __ _ ___| |_(_) __ _ ___"
s" //_\\/ __|/ _` | | __|/ _ \ | | | | / __|/ _` / __| __| |/ _` |/ _ \"
s" / _ \__ \ (_| | | |_| (_) | | |_| | | (__| (_| \__ \ |_| | (_| | (_) |"
s" \_/ \_/___/\__,_|_|\__|\___/ \__, | \___|\__,_|___/\__|_|\__, |\___/"
s" |___/ |___/"
6 \ lines
;
: maxfour ( -- a0 u0 ... a3 u3 4 )
s" /\ | | | '"
s" /__\ (~/~~||~|~/~\ \ / /~~/~~|(~~|~|/~~|/~\"
s" / \_)\__|| | \_/ \/ \__\__|_) | |\__|\_/"
s" _/ \__|"
4 \ lines
;
end-package
\ ==============================================================
\ Change log
\ 2012-04-29 First version.
\
\ 2012-09-14 Removed unused mroll.fs. Code reformated.
\
\ 2013-11-06 Changed the stack notation of flag.
\
\ 2014-11-17: Module name updated.
\
\ 2017-08-17: Update change log layout. Update header. Update stack
\ notation.
\
\ 2017-08-18: Use `package` instead of `module:`.