mirror of https://github.com/liamg/aminal.git
commit
3ac20e62fb
|
@ -75,6 +75,7 @@ go build
|
|||
| Select word | double click |
|
||||
| Select line | triple click |
|
||||
| Copy | ctrl + shift + c |
|
||||
| Toggle debug display | ctrl + shift + d |
|
||||
| Paste | ctrl + shift + v |
|
||||
| Google selected text | ctrl + shift + g |
|
||||
| Report bug in aminal | ctrl + shift + r |
|
||||
|
|
|
@ -413,6 +413,14 @@ func (buffer *Buffer) convertViewLineToRawLine(viewLine uint16) uint64 {
|
|||
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
|
||||
func (buffer *Buffer) Width() uint16 {
|
||||
return buffer.viewWidth
|
||||
|
@ -949,19 +957,14 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
|||
}
|
||||
}
|
||||
|
||||
fromBottom := buffer.viewHeight - buffer.cursorY
|
||||
|
||||
buffer.viewWidth = width
|
||||
buffer.viewHeight = height
|
||||
|
||||
if buffer.cursorY >= buffer.viewHeight-1 {
|
||||
buffer.cursorY = buffer.viewHeight - 1
|
||||
} else {
|
||||
buffer.cursorY = (buffer.viewHeight - fromBottom) + uint16(cursorYMovement)
|
||||
if int(buffer.cursorY) >= buffer.Height() {
|
||||
buffer.cursorY = uint16(buffer.Height() - 1)
|
||||
}
|
||||
cY := uint16(len(buffer.lines) - 1)
|
||||
if cY >= buffer.viewHeight {
|
||||
cY = buffer.viewHeight - 1
|
||||
}
|
||||
buffer.cursorY = cY
|
||||
|
||||
// position cursorX
|
||||
line = buffer.getCurrentLine()
|
||||
|
|
16
gui/gui.go
16
gui/gui.go
|
@ -33,6 +33,7 @@ type GUI struct {
|
|||
mouseDown bool
|
||||
overlay overlay
|
||||
terminalAlpha float32
|
||||
showDebugInfo bool
|
||||
}
|
||||
|
||||
func New(config *config.Config, terminal *terminal.Terminal, logger *zap.SugaredLogger) *GUI {
|
||||
|
@ -250,6 +251,21 @@ func (gui *GUI) Render() error {
|
|||
|
||||
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()
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti
|
|||
case glfw.KeyC:
|
||||
gui.window.SetClipboardString(gui.terminal.ActiveBuffer().GetSelectedText())
|
||||
return
|
||||
case glfw.KeyD:
|
||||
gui.showDebugInfo = !gui.showDebugInfo
|
||||
gui.terminal.SetDirty()
|
||||
case glfw.KeyG:
|
||||
keywords := gui.terminal.ActiveBuffer().GetSelectedText()
|
||||
if keywords != "" {
|
||||
|
|
BIN
sixel/img.bmp
BIN
sixel/img.bmp
Binary file not shown.
Before Width: | Height: | Size: 418 B |
|
@ -1,14 +1,9 @@
|
|||
package sixel
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/image/bmp"
|
||||
)
|
||||
|
||||
// from https://en.wikipedia.org/wiki/Sixel
|
||||
|
@ -26,19 +21,4 @@ func TestParsing(t *testing.T) {
|
|||
img := six.RGBA()
|
||||
require.NotNil(t, img)
|
||||
|
||||
var imageBuf bytes.Buffer
|
||||
err = bmp.Encode(io.Writer(&imageBuf), img)
|
||||
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
// Write to file.
|
||||
fo, err := os.Create("img.bmp")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer fo.Close()
|
||||
fo.Write(imageBuf.Bytes())
|
||||
|
||||
}
|
||||
|
|
|
@ -289,13 +289,12 @@ func (terminal *Terminal) SetSize(newCols uint, newLines uint) error {
|
|||
terminal.size.Width = uint16(newCols)
|
||||
terminal.size.Height = uint16(newLines)
|
||||
|
||||
terminal.ActiveBuffer().ResizeView(terminal.size.Width, terminal.size.Height)
|
||||
|
||||
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(terminal.pty.Fd()),
|
||||
uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(&terminal.size)))
|
||||
if err != 0 {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue