mirror of https://github.com/liamg/aminal.git
Merge pull request #41 from liamg/fix-osx-framebuffer-issues
fix osx framebuffer issues
This commit is contained in:
commit
700bbb9af9
|
@ -616,8 +616,6 @@ func (buffer *Buffer) incrementCursorPosition() {
|
|||
|
||||
buffer.cursorX++
|
||||
|
||||
} else {
|
||||
fmt.Println("cursor position invalid")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,7 +778,13 @@ func (buffer *Buffer) DeleteChars(n int) {
|
|||
defer buffer.emitDisplayChange()
|
||||
|
||||
line := buffer.getCurrentLine()
|
||||
if int(buffer.cursorX) >= len(line.cells) {
|
||||
return
|
||||
}
|
||||
before := line.cells[:buffer.cursorX]
|
||||
if int(buffer.cursorX)+n >= len(line.cells) {
|
||||
n = len(line.cells) - int(buffer.cursorX)
|
||||
}
|
||||
after := line.cells[int(buffer.cursorX)+n:]
|
||||
line.cells = append(before, after...)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import (
|
|||
"golang.org/x/image/math/fixed"
|
||||
)
|
||||
|
||||
const DPI = 72
|
||||
|
||||
// A Font allows rendering of text to an OpenGL context.
|
||||
type Font struct {
|
||||
characters map[rune]*character
|
||||
|
@ -213,7 +215,7 @@ func (f *Font) GetRune(r rune) (*character, error) {
|
|||
//create new face to measure glyph diamensions
|
||||
ttfFace := truetype.NewFace(f.ttf, &truetype.Options{
|
||||
Size: float64(f.scale),
|
||||
DPI: 72,
|
||||
DPI: DPI,
|
||||
Hinting: font.HintingFull,
|
||||
})
|
||||
|
||||
|
@ -257,7 +259,7 @@ func (f *Font) GetRune(r rune) (*character, error) {
|
|||
|
||||
//create a freetype context for drawing
|
||||
c := freetype.NewContext()
|
||||
c.SetDPI(72)
|
||||
c.SetDPI(DPI)
|
||||
c.SetFont(f.ttf)
|
||||
c.SetFontSize(float64(f.scale))
|
||||
c.SetClip(rgba.Bounds())
|
||||
|
|
|
@ -41,7 +41,7 @@ func LoadTrueTypeFont(program uint32, r io.Reader, scale float32) (*Font, error)
|
|||
|
||||
ttfFace := truetype.NewFace(f.ttf, &truetype.Options{
|
||||
Size: float64(f.scale),
|
||||
DPI: 72,
|
||||
DPI: DPI,
|
||||
Hinting: font.HintingFull,
|
||||
})
|
||||
|
||||
|
|
19
gui/gui.go
19
gui/gui.go
|
@ -37,8 +37,8 @@ func New(config *config.Config, terminal *terminal.Terminal, logger *zap.Sugared
|
|||
return &GUI{
|
||||
config: config,
|
||||
logger: logger,
|
||||
width: 600,
|
||||
height: 300,
|
||||
width: 800,
|
||||
height: 600,
|
||||
terminal: terminal,
|
||||
fontScale: 14.0,
|
||||
}
|
||||
|
@ -54,16 +54,21 @@ func (gui *GUI) resize(w *glfw.Window, width int, height int) {
|
|||
gui.width = width
|
||||
gui.height = height
|
||||
|
||||
ww, wh := w.GetSize()
|
||||
|
||||
hScale := float32(ww) / float32(width)
|
||||
vScale := float32(wh) / float32(height)
|
||||
|
||||
gui.logger.Debugf("Updating font resolution...")
|
||||
if gui.font != nil {
|
||||
gui.font.UpdateResolution((width), (height))
|
||||
gui.font.UpdateResolution(int(float32(width)*hScale), int(float32(height)*vScale))
|
||||
}
|
||||
if gui.boldFont != nil {
|
||||
gui.boldFont.UpdateResolution((width), (height))
|
||||
gui.boldFont.UpdateResolution(int(float32(width)*hScale), int(float32(height)*vScale))
|
||||
}
|
||||
|
||||
gui.logger.Debugf("Setting renderer area...")
|
||||
gui.renderer.SetArea(0, 0, gui.width, gui.height)
|
||||
gui.renderer.SetArea(0, 0, int(float32(width)*hScale), int(float32(height)*vScale))
|
||||
|
||||
gui.logger.Debugf("Calculating size in cols/rows...")
|
||||
cols, rows := gui.renderer.GetTermSize()
|
||||
|
@ -106,7 +111,7 @@ func (gui *GUI) Render() error {
|
|||
|
||||
gui.logger.Debugf("Creating window...")
|
||||
var err error
|
||||
gui.window, err = gui.createWindow(500, 300)
|
||||
gui.window, err = gui.createWindow(gui.width, gui.height)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create window: %s", err)
|
||||
}
|
||||
|
@ -144,7 +149,7 @@ func (gui *GUI) Render() error {
|
|||
gui.terminal.SetDirty()
|
||||
}
|
||||
})
|
||||
w, h := gui.window.GetSize()
|
||||
w, h := gui.window.GetFramebufferSize()
|
||||
gui.resize(gui.window, w, h)
|
||||
|
||||
gui.logger.Debugf("Starting pty read handling...")
|
||||
|
|
Loading…
Reference in New Issue