summary refs log tree commit diff stats
path: root/interface
diff options
context:
space:
mode:
Diffstat (limited to 'interface')
-rw-r--r--interface/ncurses.rb68
1 files changed, 55 insertions, 13 deletions
diff --git a/interface/ncurses.rb b/interface/ncurses.rb
index 0d2659e4..a383a570 100644
--- a/interface/ncurses.rb
+++ b/interface/ncurses.rb
@@ -9,8 +9,18 @@ module Interface
 			'<cr>'
 		when ?\b, Ncurses::KEY_BACKSPACE
 			'<bs>'
+		when Ncurses::KEY_RIGHT
+			'<right>'
+		when Ncurses::KEY_LEFT
+			'<left>'
+		when Ncurses::KEY_UP
+			'<up>'
+		when Ncurses::KEY_DOWN
+			'<down>'
 		when ?\e
 			'<esc>'
+#		when ?\s
+#			'<space>'
 		when ?\t
 			'<tab>'
 		when 32
@@ -18,6 +28,7 @@ module Interface
 		when 0..127
 			key.chr
 		else
+			log(key)
 			''
 		end
 	end
@@ -83,10 +94,9 @@ module Interface
 		Ncurses.start_color
 		Ncurses.use_default_colors
 
-#		Ncurses.cbreak
 		Ncurses.noecho
 		Ncurses.curs_set 0
-		Ncurses.halfdelay(1000)
+		Ncurses.halfdelay(10000)
 		@@colortable = []
 	end
 
@@ -97,15 +107,16 @@ module Interface
 		Ncurses.endwin
 	end
 
+	def cleari
+		Ncurses.mvaddstr(0, 0, ' ' * (lines * cols))
+	end
+
 	def geti
 		Interface::keytable(Ncurses.getch)
 	end
 
 	def set_title(x)
-#		closei
-		print "\e]2;#{x}\007"
-#		system('echo', '-n', '-e', '"\e2;' + x + '\007"')
-#		starti
+		print "\e]2;#{x}\b"
 	end
 
 	def lines
@@ -135,22 +146,53 @@ module Interface
 	end
 
 	def color(fg = -1, bg = -1)
-		Ncurses.color_set(get_color(fg,bg), nil)
+		if OPTIONS['color']
+			Ncurses.color_set(get_color(fg,bg), nil)
+		end
 	end
 
 	def color_at y, x=0, len=-1, fg=-1, bg=-1
-		if y < 0 then y += Ncurses.LINES end
-		Ncurses.mvchgat(y, x, len, 0, get_color(fg, bg), nil)
+		if OPTIONS['color']
+			if y < 0 then y += Ncurses.LINES end
+			Ncurses.mvchgat(y, x, len, 0, get_color(fg, bg), nil)
+		end
 	end
 
 	def color_bold_at y, x=0, len=-1, fg=-1, bg=-1
-		if y < 0 then y += Ncurses.LINES end
-		Ncurses.mvchgat(y, x, len, Ncurses::A_BOLD, get_color(fg, bg), nil)
+		if OPTIONS['color']
+			if y < 0 then y += Ncurses.LINES end
+			Ncurses.mvchgat(y, x, len, Ncurses::A_BOLD, get_color(fg, bg), nil)
+		end
 	end
 
 	def color_reverse_at y, x=0, len=-1, fg=-1, bg=-1
-		if y < 0 then y += Ncurses.LINES end
-		Ncurses.mvchgat(y, x, len, Ncurses::A_REVERSE, get_color(fg, bg), nil)
+		if OPTIONS['color']
+			if y < 0 then y += Ncurses.LINES end
+			Ncurses.mvchgat(y, x, len, Ncurses::A_REVERSE, get_color(fg, bg), nil)
+		else
+			Ncurses.mvchgat(y, x, len, Ncurses::A_REVERSE, 0, nil)
+		end
+	end
+
+#	runi(:command => String/Array, :wait=>false)
+#	runi('ä́', 'b', 'c')
+	def runi(hash, *args)
+		wait = false
+		if Array === hash
+			command = hash
+		elsif String === hash
+			command = [hash, *args]
+		else
+			command = hash[:command] or return false
+			wait = hash[:wait] if hash.has_key? :wait
+		end
+
+		closei
+
+		system(*command)
+		gets if wait
+
+		starti
 	end
 
 	def get_color(fg, bg)
rtik Agaram <vc@akkartik.com> 2020-01-02 01:41:55 -0800 committer Kartik Agaram <vc@akkartik.com> 2020-01-02 02:01:41 -0800 5865' href='/akkartik/mu/commit/translate_subx_emulated?h=main&id=9e5e87ca3776efa5f0d772ed8cf348bf6ee4d08e'>9e5e87ca ^
9e5e87ca ^
9e5e87ca ^
531f14c9 ^

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
         

                                                                          

                 
                                                        

                                                              







                                                                             


                                           
 
       
 
                                                             
                                                            
                                                             
                                                            
                                                              
                                                             
                                                           
                                                             
                                                          

              
#!/bin/sh
# Translate SubX by running the self-hosted translator in emulated mode on
# Linux or BSD or Mac.
#
# Possible knobs:
#   Whether to run a phase natively or in emulated mode.
#     Just always emulate for now since we debug on non-Linux.
#   Whether to stop after a phase.
#     Just always run all phases, but print out phases so it's clear where an
#     error happens.
#   Whether to trace a phase. Whether to always trace or rerun with tracing
#   enabled after an error.
#     Leave tracing to other scripts. We save intermediate files so it's easy
#     to rerun a single phase afterwards.
#   Whether to run a phase with debug information. (Need to juggle multiple
#   sets of debug files.)
#     Again, that's for subsequent scripts.

set -e

./build

cat $*          |./bootstrap_bin run apps/braces   > a.braces
cat a.braces    |./bootstrap_bin run apps/calls    > a.calls
cat a.calls     |./bootstrap_bin run apps/sigils   > a.sigils
cat a.sigils    |./bootstrap_bin run apps/tests    > a.tests
cat a.tests     |./bootstrap_bin run apps/dquotes  > a.dquotes
cat a.dquotes   |./bootstrap_bin run apps/assort   > a.assort
cat a.assort    |./bootstrap_bin run apps/pack     > a.pack
cat a.pack      |./bootstrap_bin run apps/survey   > a.survey
cat a.survey    |./bootstrap_bin run apps/hex      > a.elf

chmod +x a.elf