mirror of https://github.com/liamg/aminal.git
debug mode
This commit is contained in:
parent
6a643a763e
commit
c7ef0874aa
|
@ -413,6 +413,14 @@ func (buffer *Buffer) convertViewLineToRawLine(viewLine uint16) uint64 {
|
||||||
return uint64(int(viewLine) + (rawHeight - int(buffer.viewHeight)))
|
return uint64(int(viewLine) + (rawHeight - int(buffer.viewHeight)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (buffer *Buffer) convertRawLineToViewLine(rawLine uint64) uint16 {
|
||||||
|
rawHeight := buffer.Height()
|
||||||
|
if int(buffer.viewHeight) > rawHeight {
|
||||||
|
return uint16(rawLine)
|
||||||
|
}
|
||||||
|
return uint16(int(rawLine) - (rawHeight - int(buffer.viewHeight)))
|
||||||
|
}
|
||||||
|
|
||||||
// Width returns the width of the buffer in columns
|
// Width returns the width of the buffer in columns
|
||||||
func (buffer *Buffer) Width() uint16 {
|
func (buffer *Buffer) Width() uint16 {
|
||||||
return buffer.viewWidth
|
return buffer.viewWidth
|
||||||
|
@ -938,19 +946,14 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fromBottom := buffer.viewHeight - buffer.cursorY
|
|
||||||
|
|
||||||
buffer.viewWidth = width
|
buffer.viewWidth = width
|
||||||
buffer.viewHeight = height
|
buffer.viewHeight = height
|
||||||
|
|
||||||
if buffer.cursorY >= buffer.viewHeight-1 {
|
cY := uint16(len(buffer.lines) - 1)
|
||||||
buffer.cursorY = buffer.viewHeight - 1
|
if cY >= buffer.viewHeight {
|
||||||
} else {
|
cY = buffer.viewHeight - 1
|
||||||
buffer.cursorY = (buffer.viewHeight - fromBottom) + uint16(cursorYMovement)
|
|
||||||
if int(buffer.cursorY) >= buffer.Height() {
|
|
||||||
buffer.cursorY = uint16(buffer.Height() - 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
buffer.cursorY = cY
|
||||||
|
|
||||||
// position cursorX
|
// position cursorX
|
||||||
line = buffer.getCurrentLine()
|
line = buffer.getCurrentLine()
|
||||||
|
|
16
gui/gui.go
16
gui/gui.go
|
@ -33,6 +33,7 @@ type GUI struct {
|
||||||
mouseDown bool
|
mouseDown bool
|
||||||
overlay overlay
|
overlay overlay
|
||||||
terminalAlpha float32
|
terminalAlpha float32
|
||||||
|
showDebugInfo bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *config.Config, terminal *terminal.Terminal, logger *zap.SugaredLogger) *GUI {
|
func New(config *config.Config, terminal *terminal.Terminal, logger *zap.SugaredLogger) *GUI {
|
||||||
|
@ -250,6 +251,21 @@ func (gui *GUI) Render() error {
|
||||||
|
|
||||||
gui.renderOverlay()
|
gui.renderOverlay()
|
||||||
|
|
||||||
|
if gui.showDebugInfo {
|
||||||
|
gui.textbox(2, 2, fmt.Sprintf(`Debug Panel
|
||||||
|
===========
|
||||||
|
Cursor: %d,%d
|
||||||
|
View Size: %d,%d
|
||||||
|
Buffer Size: %d lines
|
||||||
|
`,
|
||||||
|
gui.terminal.GetLogicalCursorX(),
|
||||||
|
gui.terminal.GetLogicalCursorY(),
|
||||||
|
gui.terminal.ActiveBuffer().ViewWidth(),
|
||||||
|
gui.terminal.ActiveBuffer().ViewHeight(),
|
||||||
|
gui.terminal.ActiveBuffer().Height(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
gui.window.SwapBuffers()
|
gui.window.SwapBuffers()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti
|
||||||
case glfw.KeyC:
|
case glfw.KeyC:
|
||||||
gui.window.SetClipboardString(gui.terminal.ActiveBuffer().GetSelectedText())
|
gui.window.SetClipboardString(gui.terminal.ActiveBuffer().GetSelectedText())
|
||||||
return
|
return
|
||||||
|
case glfw.KeyD:
|
||||||
|
gui.showDebugInfo = !gui.showDebugInfo
|
||||||
|
gui.terminal.SetDirty()
|
||||||
case glfw.KeyG:
|
case glfw.KeyG:
|
||||||
keywords := gui.terminal.ActiveBuffer().GetSelectedText()
|
keywords := gui.terminal.ActiveBuffer().GetSelectedText()
|
||||||
if keywords != "" {
|
if keywords != "" {
|
||||||
|
|
BIN
sixel/img.bmp
BIN
sixel/img.bmp
Binary file not shown.
Before Width: | Height: | Size: 614 B |
|
@ -289,13 +289,12 @@ func (terminal *Terminal) SetSize(newCols uint, newLines uint) error {
|
||||||
terminal.size.Width = uint16(newCols)
|
terminal.size.Width = uint16(newCols)
|
||||||
terminal.size.Height = uint16(newLines)
|
terminal.size.Height = uint16(newLines)
|
||||||
|
|
||||||
terminal.ActiveBuffer().ResizeView(terminal.size.Width, terminal.size.Height)
|
|
||||||
|
|
||||||
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(terminal.pty.Fd()),
|
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(terminal.pty.Fd()),
|
||||||
uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(&terminal.size)))
|
uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(&terminal.size)))
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
return fmt.Errorf("Failed to set terminal size vai ioctl: Error no %d", err)
|
return fmt.Errorf("Failed to set terminal size vai ioctl: Error no %d", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
terminal.ActiveBuffer().ResizeView(terminal.size.Width, terminal.size.Height)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue