Skip to content

Commit

Permalink
#1 Add renderStyle command option and fancy unicode render
Browse files Browse the repository at this point in the history
  • Loading branch information
birchb1024 committed Oct 17, 2021
1 parent 592f7ec commit 4142ab0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 47 deletions.
90 changes: 45 additions & 45 deletions default.betula
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@

1
0
Q @L
Q*-L | H* L L L
| 1 | 1 1 32C--N--@ _Comment C * 1C cdef
| 0 | 0 0 32C--N--@ _Comment C * 1C cdef
C-L----/ | \-L-----L | |
| | 2 |11 |0
1 | 1 | H 2*-------L 9*---S~L @-S~-L q
L--@---L @-L | 91 |90
|1 @-------@ n
@L n*--L
Q1 n*--L
8 w* 8* @---Z--J 8*1 n*--L
L-/ |w \----@ 32C--@ | |0 @L 30C--LJ
1 @L t | |1 Q* 32C @J n*--J
32CL L 3*----|--S--@ | |1 Q 1*1 n*--J
N 32C1 0C | 3 3 |3 @---S--L n*--J
|0 3*@---S---J N @L Q n
9*--S--L | 3 3 3 |0 |
| 90 | 4*----S-----@
| | 32C1 3 4 3 1*1
|32C1 9 @---S---L 14C--S--J
@--S--L 3 1 1 3 3 3
9 2CL 32CL _SPDT Relay_ b
1*1 f | | 52C-N L
| | 2 |0 |1 1
0 | 0 | H 2*-------L 9*---S~L @-S~-L q
L--@---L @-L | 90 |91
|0 @-------@ c
@L c*--L
Q c*--L
8 w* 8* @---Z--J 8*1 c*--L
L-/ |w \----@ 32C--@ | |1 Q @L 30C--LJ
0 @L 6 | |0 Q* 32C @J c*--J
32CL L 3*----|--S--@ | |0 1*1 c*--J
N 32C0 0C | 3 |4 @---S--L c*--J
|1 9 3*@---S---J N @L Q0 c
9*--S--L | 30 |1 |
| 9 9 | 4*----S-----@
| | 32C0 4 4 1*1
|32C0 @---S---L 14C--S--J
@--S--L 30 0 0 0 0 0
90 2CL 32CL _SPDT Relay_ o
1*1 0 | | 52C-N L
1gC----S---L N N | | 00C---@
f f |0 |0 |0| | 0
@L @L 1gC----S-|----@J 0=-LB
| f | |
Mrelay | |1 f @---@ 0*
_Diodes_ C@--@--@-@ @------S----@L N---@ | | 1
1 1 | |13 f f 0 | | 1=---L
0 0 |1 |1 |1| | 0
@L @L 1gC----S-|-----J 0=-LB
| 0 0| 0 |
Mrelay | |0 @---@ 0*
_Diodes_ C@--@--@-@ @------S-----L N---@ | | 0
0 | |0 0 0 | | 0=---L
32C->-L 32CL<-J 3*@--|--S-L 3*--S---@ | |
| N03 3 3 | 2*
| N13 3 3 | 2*
@--S----L |
10C b 00C 3 9R 33C---@ 3*--@
L->-@ L-<-@ | 0_Equals_ | | 0 | 0
_Random_ 0=-L | 0=---L 0=---L
10C o 00C 3 3 9R 33C---@ 3*--@
L->-@ L-<-@ | 0_Equals_ | | 1 | 0
_Random_ 0=-L | 1=---L 0=---L
C C | | | |
>J J< 2R 9R | 0* 1gC
1 1 | @---@ 0* |
|12 a | | 0 | 1 @---@
a*--S---L 22C 0^--L 1=--L | 0
| @---@ 0* |
|12 a | | 1 | 1 @---@
a*--S---L 22C 1^--L 1=--L | 0
a a | | | 0=---L
Mspdt @---@ | |
t1 0* 1*
t*@-@--Z--J Q1
| 1|0 Q*--Z--L
12C@-|-L@ 22C0
| |1 t
@-@--S--L 22C1 Q @----@
t Q*--S--L 11 |0 | 1
Q Q 1*---Z---L-----S----|--~-@-L
1 |0 _A_ 0 | |
t 0* 1*
t*@-@--Z--J Q Q
| 0|1 t Q*--Z--L
12C@-|-L@ 22C1
| |0
@-@--S--L 22C0 @----@
t0 Q*--S--L 1 1 |1 | 1
Q0 1*---Z---L-----S----|--~-@-L
0 |1 _A_ 1 | |
_B_ 32CL-----@ 52CJ-------@ | _ XOR with switches _
|1 1 0 1 | |
|0 1 11 | |
1*----S---L-----Z----|----@
1 1 |1 |
10 |0 |
@----@
22 changes: 20 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,7 @@ func (e *editor) style(p coord, cellStyle tcell.Style) tcell.Style {

var renderTime = flag.Duration("renderTime", 100 * time.Millisecond, "How frequently to refresh the screen.")
var clockSpeed = flag.Duration("clockSpeed", 50 * time.Millisecond, "How frequently to run the interpreter.")
var renderStyle = flag.String("renderStyle", "unicode", "Render style [plain, unicode], default unicode.")

// var prof interface{ Stop() } // Keep this line

Expand Down Expand Up @@ -1362,6 +1363,23 @@ func main() {
}
}

func fancy(r rune) rune {
if *renderStyle != "unicode" {
return r
}
f, ok := boxDrawRunes[r]
if !ok {
return r
}
return f
}
var boxDrawRunes = map[rune]rune{
'|' : '│',
'-' : '─',
'@' : '█',
// lookups here: https://unicode-table.com/en/blocks/box-drawing/
}

var colors = map[rune]tcell.Color{
'=': tcell.ColorBlack,
'.': tcell.ColorBlack,
Expand Down Expand Up @@ -1472,11 +1490,11 @@ func view(s tcell.Screen, b board) {
sty = commentStyle
}
stile := theEditor.style(coord{x, y}, sty)
s.SetContent(x, y, b[x][y], nil, stile)
s.SetContent(x, y, fancy(b.get(x, y)), nil, stile)
}
}
for x := 0; x < width; x++ {
s.SetContent(x, height-1, b[x][height-1], nil, tcell.StyleDefault)
s.SetContent(x, height-1, fancy(b[x][height-1]), nil, tcell.StyleDefault)
}
s.SetContent(cursorX, cursorY, b.get(cursorX, cursorY), nil, tcell.StyleDefault.Reverse(true))
boardMutex.Unlock()
Expand Down

0 comments on commit 4142ab0

Please sign in to comment.