mirror of https://github.com/liamg/aminal.git
improve render efficiency
This commit is contained in:
parent
6fbcc3003e
commit
5ae70eeedc
12
README.md
12
README.md
|
@ -43,7 +43,7 @@ Ensure you have your latest graphics card drivers installed before use.
|
|||
| UTF-8 output | ✔ | Works as long as the font in use supports the relevant characters.
|
||||
| Copy/paste | | Paste working, no mouse interaction for copy
|
||||
| Customisable colour schemes | ✔ | Complete, but the config file has no entry for this yet
|
||||
| Config file | | Minimal options atm
|
||||
| Config file | ✔ | Minimal options atm
|
||||
| Scrolling | | Infinite buffer implemented, need GUI scrollbar & render updates
|
||||
| Mouse interaction | |
|
||||
| Sweet render effects | |
|
||||
|
@ -63,9 +63,17 @@ The following options are available:
|
|||
|---------------|---------|---------|-----------------------|
|
||||
| debug | bool | False | Enables debug logging
|
||||
|
||||
|
||||
## Flags
|
||||
|
||||
| Name | Type | Default |Description |
|
||||
|-----------------|---------|---------|-----------------------|
|
||||
| --debug | bool | False | Enables debug logging |
|
||||
| --ignore-config | bool | False | Ignores user config files and uses defaults
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
| Operation | Key(s) |
|
||||
|-----------|---------------------|
|
||||
| Paste | ctrl + alt + v
|
||||
|||
|
||||
|
||||
|
|
50
gui/cell.go
50
gui/cell.go
|
@ -13,8 +13,10 @@ type Cell struct {
|
|||
cv uint32
|
||||
colourAttr uint32
|
||||
points []float32
|
||||
colour [3]float32
|
||||
bgColour [3]float32
|
||||
fgColour [3]float32
|
||||
hidden bool
|
||||
r rune
|
||||
}
|
||||
|
||||
func (gui *GUI) NewCell(font *v41.Font, x float32, y float32, w float32, h float32, colourAttr uint32, bgColour [3]float32) Cell {
|
||||
|
@ -23,7 +25,7 @@ func (gui *GUI) NewCell(font *v41.Font, x float32, y float32, w float32, h float
|
|||
colourAttr: colourAttr,
|
||||
}
|
||||
|
||||
cell.colour = bgColour
|
||||
cell.bgColour = bgColour
|
||||
cell.text.SetPosition(mgl32.Vec2{x, y})
|
||||
|
||||
x = (x - (w / 2)) / (float32(gui.width) / 2)
|
||||
|
@ -45,19 +47,34 @@ func (gui *GUI) NewCell(font *v41.Font, x float32, y float32, w float32, h float
|
|||
|
||||
}
|
||||
|
||||
func (cell *Cell) SetFgColour(r, g, b float32) {
|
||||
func (cell *Cell) SetRune(r rune) {
|
||||
if cell.r == r {
|
||||
return
|
||||
}
|
||||
if cell.text != nil {
|
||||
if r == '%' {
|
||||
cell.text.SetString("%%")
|
||||
} else {
|
||||
cell.text.SetString(string(r))
|
||||
}
|
||||
}
|
||||
cell.r = r
|
||||
}
|
||||
|
||||
func (cell *Cell) SetFgColour(r, g, b float32) {
|
||||
if cell.text != nil && (cell.fgColour[0] != r || cell.fgColour[1] != g || cell.fgColour[2] != b) {
|
||||
cell.fgColour = [3]float32{r, g, b}
|
||||
cell.text.SetColor(mgl32.Vec3{r, g, b})
|
||||
}
|
||||
}
|
||||
|
||||
func (cell *Cell) SetBgColour(r float32, g float32, b float32) {
|
||||
|
||||
if cell.colour[0] == r && cell.colour[1] == g && cell.colour[2] == b {
|
||||
if cell.bgColour[0] == r && cell.bgColour[1] == g && cell.bgColour[2] == b {
|
||||
return
|
||||
}
|
||||
|
||||
cell.colour = [3]float32{r, g, b}
|
||||
cell.bgColour = [3]float32{r, g, b}
|
||||
cell.Clean()
|
||||
cell.makeVao()
|
||||
}
|
||||
|
@ -83,12 +100,12 @@ func (cell *Cell) makeVao() {
|
|||
gl.GenBuffers(1, &cell.cv)
|
||||
gl.BindBuffer(gl.ARRAY_BUFFER, cell.cv)
|
||||
triColor := []float32{
|
||||
cell.colour[0], cell.colour[1], cell.colour[2],
|
||||
cell.colour[0], cell.colour[1], cell.colour[2],
|
||||
cell.colour[0], cell.colour[1], cell.colour[2],
|
||||
cell.colour[0], cell.colour[1], cell.colour[2],
|
||||
cell.colour[0], cell.colour[1], cell.colour[2],
|
||||
cell.colour[0], cell.colour[1], cell.colour[2],
|
||||
cell.bgColour[0], cell.bgColour[1], cell.bgColour[2],
|
||||
cell.bgColour[0], cell.bgColour[1], cell.bgColour[2],
|
||||
cell.bgColour[0], cell.bgColour[1], cell.bgColour[2],
|
||||
cell.bgColour[0], cell.bgColour[1], cell.bgColour[2],
|
||||
cell.bgColour[0], cell.bgColour[1], cell.bgColour[2],
|
||||
cell.bgColour[0], cell.bgColour[1], cell.bgColour[2],
|
||||
}
|
||||
gl.BufferData(gl.ARRAY_BUFFER, len(triColor)*4, gl.Ptr(triColor), gl.STATIC_DRAW)
|
||||
gl.EnableVertexAttribArray(cell.colourAttr)
|
||||
|
@ -124,17 +141,6 @@ func (cell *Cell) Hide() {
|
|||
cell.hidden = true
|
||||
}
|
||||
|
||||
func (cell *Cell) SetRune(r rune) {
|
||||
if cell.text != nil {
|
||||
if r == '%' {
|
||||
cell.text.SetString("%%")
|
||||
} else {
|
||||
cell.text.SetString(string(r))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (cell *Cell) Release() {
|
||||
if cell.text != nil {
|
||||
cell.text.Release()
|
||||
|
|
17
main.go
17
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -12,7 +13,19 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func loadConfig() config.Config {
|
||||
func getConfig() config.Config {
|
||||
ignore := false
|
||||
flag.BoolVar(&ignore, "ignore-config", ignore, "Ignore user config files and use defauls")
|
||||
if ignore {
|
||||
return config.DefaultConfig
|
||||
}
|
||||
conf := loadConfigFile()
|
||||
flag.BoolVar(&conf.DebugMode, "debug", conf.DebugMode, "Enable debug logging")
|
||||
flag.Parse()
|
||||
return conf
|
||||
}
|
||||
|
||||
func loadConfigFile() config.Config {
|
||||
|
||||
home := os.Getenv("HOME")
|
||||
if home == "" {
|
||||
|
@ -56,7 +69,7 @@ func getLogger(conf config.Config) (*zap.SugaredLogger, error) {
|
|||
func main() {
|
||||
|
||||
// parse this
|
||||
conf := loadConfig()
|
||||
conf := getConfig()
|
||||
|
||||
logger, err := getLogger(conf)
|
||||
if err != nil {
|
||||
|
|
|
@ -394,9 +394,9 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
|||
default:
|
||||
terminal.logger.Errorf("Unknown OSC control sequence: 0x%02X", b)
|
||||
}
|
||||
case rune('c'):
|
||||
case 'c':
|
||||
terminal.logger.Errorf("RIS not yet supported")
|
||||
case rune(')'), rune('('):
|
||||
case ')', '(':
|
||||
b = <-buffer
|
||||
// todo charset changes
|
||||
//terminal.logger.Debugf("Ignoring character set control code )%s", string(b))
|
||||
|
@ -424,12 +424,19 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
|||
case 0x08:
|
||||
// backspace
|
||||
terminal.position.Col--
|
||||
if terminal.position.Col < 0 {
|
||||
terminal.position.Col = 0
|
||||
}
|
||||
case 0x07:
|
||||
// @todo ring bell
|
||||
default:
|
||||
// render character at current location
|
||||
// fmt.Printf("%s\n", string([]byte{b}))
|
||||
if b >= 0x20 {
|
||||
terminal.writeRune(b)
|
||||
} else {
|
||||
terminal.logger.Error("Non-readable rune received: 0x%X", b)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ func (terminal *Terminal) getBufferedLine(line int) *Line {
|
|||
line = len(terminal.lines) - int(terminal.size.Height) + line
|
||||
}
|
||||
|
||||
if line >= len(terminal.lines) {
|
||||
if line < 0 || line >= len(terminal.lines) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -328,6 +328,9 @@ func (terminal *Terminal) SetSize(newCols int, newLines int) error {
|
|||
terminal.position.Line = len(terminal.lines) - 1
|
||||
}
|
||||
}
|
||||
if terminal.position.Line < 0 {
|
||||
terminal.position.Line = 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue