mirror of https://github.com/liamg/aminal.git
Compare commits
7 Commits
d99bdd3bb2
...
c18b702b61
Author | SHA1 | Date |
---|---|---|
|
c18b702b61 | |
|
8d4ea4d7fe | |
|
05e7618fa1 | |
|
6fa6998aca | |
|
1f2980cbb4 | |
|
80b4d6ac9c | |
|
d1a7b7d6a1 |
|
@ -22,7 +22,13 @@ Install dependencies:
|
||||||
- `xorg-dev`
|
- `xorg-dev`
|
||||||
- `libgl1-mesa-dev`
|
- `libgl1-mesa-dev`
|
||||||
|
|
||||||
Grab a binary from the [latest release](https://github.com/liamg/darktile/releases/latest).
|
Grab a binary from the [latest release](https://github.com/liamg/darktile/releases/latest), `chmod +x` it and place it in your `$PATH`.
|
||||||
|
|
||||||
|
If you're too lazy to do the above and you like to live life on the edge, you can pipe this script to sudo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s "https://raw.githubusercontent.com/liamg/darktile/main/scripts/install.sh" | sudo bash
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ var rootCmd = &cobra.Command{
|
||||||
gui.WithFontDPI(conf.Font.DPI),
|
gui.WithFontDPI(conf.Font.DPI),
|
||||||
gui.WithFontSize(conf.Font.Size),
|
gui.WithFontSize(conf.Font.Size),
|
||||||
gui.WithFontFamily(conf.Font.Family),
|
gui.WithFontFamily(conf.Font.Family),
|
||||||
|
gui.WithOpacity(conf.Opacity),
|
||||||
}
|
}
|
||||||
|
|
||||||
if screenshotAfterMS > 0 {
|
if screenshotAfterMS > 0 {
|
||||||
|
|
|
@ -73,7 +73,7 @@ func LoadThemeFromPath(conf *Config, path string) (*termutil.Theme, error) {
|
||||||
|
|
||||||
func loadThemeFromConf(conf *Config, themeConf *Theme) (*termutil.Theme, error) {
|
func loadThemeFromConf(conf *Config, themeConf *Theme) (*termutil.Theme, error) {
|
||||||
|
|
||||||
factory := termutil.NewThemeFactory().WithOpacity(conf.Opacity)
|
factory := termutil.NewThemeFactory()
|
||||||
|
|
||||||
colours := map[termutil.Colour]string{
|
colours := map[termutil.Colour]string{
|
||||||
termutil.ColourBlack: themeConf.Black,
|
termutil.ColourBlack: themeConf.Black,
|
||||||
|
|
|
@ -14,6 +14,8 @@ import (
|
||||||
// Draw renders the terminal GUI to the ebtien window. Required to implement the ebiten interface.
|
// Draw renders the terminal GUI to the ebtien window. Required to implement the ebiten interface.
|
||||||
func (g *GUI) Draw(screen *ebiten.Image) {
|
func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
|
|
||||||
|
tmp := ebiten.NewImage(g.size.X, g.size.Y)
|
||||||
|
|
||||||
cellSize := g.fontManager.CharSize()
|
cellSize := g.fontManager.CharSize()
|
||||||
dotDepth := g.fontManager.DotDepth()
|
dotDepth := g.fontManager.DotDepth()
|
||||||
|
|
||||||
|
@ -36,10 +38,10 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
extraW := float64(g.size.X) - endX
|
extraW := float64(g.size.X) - endX
|
||||||
extraH := float64(g.size.Y) - endY
|
extraH := float64(g.size.Y) - endY
|
||||||
if extraW > 0 {
|
if extraW > 0 {
|
||||||
ebitenutil.DrawRect(screen, endX, 0, extraW, endY, defBg)
|
ebitenutil.DrawRect(tmp, endX, 0, extraW, endY, defBg)
|
||||||
}
|
}
|
||||||
if extraH > 0 {
|
if extraH > 0 {
|
||||||
ebitenutil.DrawRect(screen, 0, endY, float64(g.size.X), extraH, defBg)
|
ebitenutil.DrawRect(tmp, 0, endY, float64(g.size.X), extraH, defBg)
|
||||||
}
|
}
|
||||||
|
|
||||||
var inHighlight bool
|
var inHighlight bool
|
||||||
|
@ -52,7 +54,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
for y := int(buffer.ViewHeight() - 1); y >= 0; y-- {
|
for y := int(buffer.ViewHeight() - 1); y >= 0; y-- {
|
||||||
py := cellSize.Y * y
|
py := cellSize.Y * y
|
||||||
|
|
||||||
ebitenutil.DrawRect(screen, 0, float64(py), float64(g.size.X), float64(cellSize.Y), defBg)
|
ebitenutil.DrawRect(tmp, 0, float64(py), float64(g.size.X), float64(cellSize.Y), defBg)
|
||||||
inHighlight = false
|
inHighlight = false
|
||||||
for x := uint16(0); x < buffer.ViewWidth(); x++ {
|
for x := uint16(0); x < buffer.ViewWidth(); x++ {
|
||||||
cell := buffer.GetCell(x, uint16(y))
|
cell := buffer.GetCell(x, uint16(y))
|
||||||
|
@ -74,7 +76,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
colour = defBg
|
colour = defBg
|
||||||
}
|
}
|
||||||
|
|
||||||
ebitenutil.DrawRect(screen, float64(px), float64(py), float64(cellSize.X), float64(cellSize.Y), colour)
|
ebitenutil.DrawRect(tmp, float64(px), float64(py), float64(cellSize.X), float64(cellSize.Y), colour)
|
||||||
|
|
||||||
if buffer.IsHighlighted(termutil.Position{
|
if buffer.IsHighlighted(termutil.Position{
|
||||||
Line: uint64(y),
|
Line: uint64(y),
|
||||||
|
@ -106,7 +108,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if isCursor && !ebiten.IsFocused() {
|
if isCursor && !ebiten.IsFocused() {
|
||||||
ebitenutil.DrawRect(screen, float64(px)+1, float64(py)+1, float64(cellSize.X)-2, float64(cellSize.Y)-2, g.terminal.Theme().DefaultBackground())
|
ebitenutil.DrawRect(tmp, float64(px)+1, float64(py)+1, float64(cellSize.X)-2, float64(cellSize.Y)-2, g.terminal.Theme().DefaultBackground())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for x := uint16(0); x < buffer.ViewWidth(); x++ {
|
for x := uint16(0); x < buffer.ViewWidth(); x++ {
|
||||||
|
@ -139,13 +141,13 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
|
|
||||||
if cell.Underline() {
|
if cell.Underline() {
|
||||||
uly := float64(py + (dotDepth+cellSize.Y)/2)
|
uly := float64(py + (dotDepth+cellSize.Y)/2)
|
||||||
ebitenutil.DrawLine(screen, float64(px), uly, float64(px+cellSize.X), uly, colour)
|
ebitenutil.DrawLine(tmp, float64(px), uly, float64(px+cellSize.X), uly, colour)
|
||||||
}
|
}
|
||||||
|
|
||||||
text.Draw(screen, string(cell.Rune().Rune), useFace, px, py+dotDepth, colour)
|
text.Draw(tmp, string(cell.Rune().Rune), useFace, px, py+dotDepth, colour)
|
||||||
|
|
||||||
if cell.Strikethrough() {
|
if cell.Strikethrough() {
|
||||||
ebitenutil.DrawLine(screen, float64(px), float64(py+(cellSize.Y/2)), float64(px+cellSize.X), float64(py+(cellSize.Y/2)), colour)
|
ebitenutil.DrawLine(tmp, float64(px), float64(py+(cellSize.Y/2)), float64(px+cellSize.X), float64(py+(cellSize.Y/2)), colour)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -157,7 +159,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Translate(sx, sy)
|
op.GeoM.Translate(sx, sy)
|
||||||
screen.DrawImage(
|
tmp.DrawImage(
|
||||||
ebiten.NewImageFromImage(sixel.Sixel.Image),
|
ebiten.NewImageFromImage(sixel.Sixel.Image),
|
||||||
op,
|
op,
|
||||||
)
|
)
|
||||||
|
@ -237,19 +239,19 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw opaque box below and above highlighted line(s)
|
// draw opaque box below and above highlighted line(s)
|
||||||
ebitenutil.DrawRect(screen, 0, float64(highlightMin.Line*uint64(cellSize.Y)), float64(cellSize.X*int(highlightMin.Col)), float64(cellSize.Y), color.RGBA{A: 0x80})
|
ebitenutil.DrawRect(tmp, 0, float64(highlightMin.Line*uint64(cellSize.Y)), float64(cellSize.X*int(highlightMin.Col)), float64(cellSize.Y), color.RGBA{A: 0x80})
|
||||||
ebitenutil.DrawRect(screen, float64((cellSize.X)*int(highlightMax.Col+1)), float64(highlightMax.Line*uint64(cellSize.Y)), float64(g.size.X), float64(cellSize.Y), color.RGBA{A: 0x80})
|
ebitenutil.DrawRect(tmp, float64((cellSize.X)*int(highlightMax.Col+1)), float64(highlightMax.Line*uint64(cellSize.Y)), float64(g.size.X), float64(cellSize.Y), color.RGBA{A: 0x80})
|
||||||
ebitenutil.DrawRect(screen, 0, 0, float64(g.size.X), float64(highlightMin.Line*uint64(cellSize.Y)), color.RGBA{A: 0x80})
|
ebitenutil.DrawRect(tmp, 0, 0, float64(g.size.X), float64(highlightMin.Line*uint64(cellSize.Y)), color.RGBA{A: 0x80})
|
||||||
afterLineY := float64((1 + highlightMax.Line) * uint64(cellSize.Y))
|
afterLineY := float64((1 + highlightMax.Line) * uint64(cellSize.Y))
|
||||||
ebitenutil.DrawRect(screen, 0, afterLineY, float64(g.size.X), float64(g.size.Y)-afterLineY, color.RGBA{A: 0x80})
|
ebitenutil.DrawRect(tmp, 0, afterLineY, float64(g.size.X), float64(g.size.Y)-afterLineY, color.RGBA{A: 0x80})
|
||||||
|
|
||||||
// annotation border
|
// annotation border
|
||||||
ebitenutil.DrawRect(screen, float64(annotationX)-padding, annotationY-padding, float64(annotationWidth)+(padding*2), annotationHeight+(padding*2), g.terminal.Theme().SelectionBackground())
|
ebitenutil.DrawRect(tmp, float64(annotationX)-padding, annotationY-padding, float64(annotationWidth)+(padding*2), annotationHeight+(padding*2), g.terminal.Theme().SelectionBackground())
|
||||||
// annotation background
|
// annotation background
|
||||||
ebitenutil.DrawRect(screen, 1+float64(annotationX)-padding, 1+annotationY-padding, float64(annotationWidth)+(padding*2)-2, annotationHeight+(padding*2)-2, g.terminal.Theme().DefaultBackground())
|
ebitenutil.DrawRect(tmp, 1+float64(annotationX)-padding, 1+annotationY-padding, float64(annotationWidth)+(padding*2)-2, annotationHeight+(padding*2)-2, g.terminal.Theme().DefaultBackground())
|
||||||
|
|
||||||
// vertical line
|
// vertical line
|
||||||
ebitenutil.DrawLine(screen, lineX, float64(lineY), lineX, lineY+lineHeight, g.terminal.Theme().SelectionBackground())
|
ebitenutil.DrawLine(tmp, lineX, float64(lineY), lineX, lineY+lineHeight, g.terminal.Theme().SelectionBackground())
|
||||||
|
|
||||||
var tY int
|
var tY int
|
||||||
var tX int
|
var tX int
|
||||||
|
@ -259,7 +261,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
|
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
op.GeoM.Translate(float64(annotationX), annotationY)
|
op.GeoM.Translate(float64(annotationX), annotationY)
|
||||||
screen.DrawImage(
|
tmp.DrawImage(
|
||||||
ebiten.NewImageFromImage(annotation.Image),
|
ebiten.NewImageFromImage(annotation.Image),
|
||||||
op,
|
op,
|
||||||
)
|
)
|
||||||
|
@ -271,7 +273,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
tX = 0
|
tX = 0
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
text.Draw(screen, string(r), regularFace, annotationX+tX, int(annotationY)+dotDepth+tY, g.terminal.Theme().DefaultForeground())
|
text.Draw(tmp, string(r), regularFace, annotationX+tX, int(annotationY)+dotDepth+tY, g.terminal.Theme().DefaultForeground())
|
||||||
tX += cellSize.X
|
tX += cellSize.X
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,11 +300,11 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
boxWidth = endX / 8
|
boxWidth = endX / 8
|
||||||
}
|
}
|
||||||
|
|
||||||
ebitenutil.DrawRect(screen, float64(msgX-1), msgY-1, boxWidth+2, boxHeight+2, msg.Foreground)
|
ebitenutil.DrawRect(tmp, float64(msgX-1), msgY-1, boxWidth+2, boxHeight+2, msg.Foreground)
|
||||||
ebitenutil.DrawRect(screen, float64(msgX), msgY, boxWidth, boxHeight, msg.Background)
|
ebitenutil.DrawRect(tmp, float64(msgX), msgY, boxWidth, boxHeight, msg.Background)
|
||||||
for y, line := range lines {
|
for y, line := range lines {
|
||||||
for x, r := range line {
|
for x, r := range line {
|
||||||
text.Draw(screen, string(r), regularFace, msgX+pad+(x*cellSize.X), pad+(y*cellSize.Y)+int(msgY)+dotDepth, msg.Foreground)
|
text.Draw(tmp, string(r), regularFace, msgX+pad+(x*cellSize.X), pad+(y*cellSize.Y)+int(msgY)+dotDepth, msg.Foreground)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msgEndY = msgEndY - float64(pad*4) - float64(len(lines)*g.CellSize().Y)
|
msgEndY = msgEndY - float64(pad*4) - float64(len(lines)*g.CellSize().Y)
|
||||||
|
@ -310,7 +312,11 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.screenshotRequested {
|
if g.screenshotRequested {
|
||||||
g.takeScreenshot(screen)
|
g.takeScreenshot(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opt := &ebiten.DrawImageOptions{}
|
||||||
|
opt.ColorM.Scale(1, 1, 1, g.opacity)
|
||||||
|
screen.DrawImage(tmp, opt)
|
||||||
|
tmp.Dispose()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ type GUI struct {
|
||||||
screenshotFilename string
|
screenshotFilename string
|
||||||
startupFuncs []func(g *GUI)
|
startupFuncs []func(g *GUI)
|
||||||
keyState *keyState
|
keyState *keyState
|
||||||
|
opacity float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type PopupMessage struct {
|
type PopupMessage struct {
|
||||||
|
@ -88,6 +89,7 @@ func (g *GUI) Run() error {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ebiten.SetScreenTransparent(true)
|
ebiten.SetScreenTransparent(true)
|
||||||
|
ebiten.SetScreenClearedEveryFrame(true)
|
||||||
ebiten.SetWindowResizable(true)
|
ebiten.SetWindowResizable(true)
|
||||||
ebiten.SetRunnableOnUnfocused(true)
|
ebiten.SetRunnableOnUnfocused(true)
|
||||||
ebiten.SetFPSMode(ebiten.FPSModeVsyncOffMinimum)
|
ebiten.SetFPSMode(ebiten.FPSModeVsyncOffMinimum)
|
||||||
|
|
|
@ -168,6 +168,8 @@ func (g *GUI) handleInput() error {
|
||||||
return g.terminal.WriteToPty([]byte{0x09}) // tab
|
return g.terminal.WriteToPty([]byte{0x09}) // tab
|
||||||
|
|
||||||
case g.keyState.RepeatPressed(ebiten.KeyEscape):
|
case g.keyState.RepeatPressed(ebiten.KeyEscape):
|
||||||
|
g.terminal.GetActiveBuffer().ClearSelection()
|
||||||
|
g.terminal.GetActiveBuffer().ClearHighlight()
|
||||||
return g.terminal.WriteToPty([]byte{0x1b}) // escape
|
return g.terminal.WriteToPty([]byte{0x1b}) // escape
|
||||||
case g.keyState.RepeatPressed(ebiten.KeyBackspace):
|
case g.keyState.RepeatPressed(ebiten.KeyBackspace):
|
||||||
if ebiten.IsKeyPressed(ebiten.KeyAlt) {
|
if ebiten.IsKeyPressed(ebiten.KeyAlt) {
|
||||||
|
|
|
@ -121,6 +121,9 @@ func (g *GUI) handleMouse() error {
|
||||||
Col: uint16(col),
|
Col: uint16(col),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ebiten.ScheduleFrame()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
g.mouseDrag = false
|
g.mouseDrag = false
|
||||||
}
|
}
|
||||||
|
@ -222,7 +225,7 @@ func (g *GUI) handleClick(clickCount, x, y int) (bool, error) {
|
||||||
line := uint64(y / g.fontManager.CharSize().Y)
|
line := uint64(y / g.fontManager.CharSize().Y)
|
||||||
g.terminal.GetActiveBuffer().SelectWordAt(termutil.Position{Col: col, Line: line}, wordMatcher)
|
g.terminal.GetActiveBuffer().SelectWordAt(termutil.Position{Col: col, Line: line}, wordMatcher)
|
||||||
return true, nil
|
return true, nil
|
||||||
case 3: // triple click
|
default: // triple click (or more!)
|
||||||
g.terminal.GetActiveBuffer().ExtendSelectionToEntireLines()
|
g.terminal.GetActiveBuffer().ExtendSelectionToEntireLines()
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
@ -268,7 +271,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
|
|
||||||
tx, ty := 1+(x/g.fontManager.CharSize().X), 1+(y/g.fontManager.CharSize().Y)
|
tx, ty := 1+(x/g.fontManager.CharSize().X), 1+(y/g.fontManager.CharSize().Y)
|
||||||
|
|
||||||
mode := g.terminal.GetActiveBuffer().GetMouseMode()
|
mode := g.terminal.GetMouseMode()
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case termutil.MouseModeNone:
|
case termutil.MouseModeNone:
|
||||||
|
@ -292,7 +295,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
|
|
||||||
var button rune
|
var button rune
|
||||||
|
|
||||||
extMode := g.terminal.GetActiveBuffer().GetMouseExtMode()
|
extMode := g.terminal.GetMouseExtMode()
|
||||||
|
|
||||||
switch true {
|
switch true {
|
||||||
case pressedLeft:
|
case pressedLeft:
|
||||||
|
|
|
@ -8,6 +8,13 @@ func WithFontFamily(family string) func(g *GUI) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithOpacity(opacity float64) func(g *GUI) error {
|
||||||
|
return func(g *GUI) error {
|
||||||
|
g.opacity = opacity
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithFontSize(size float64) func(g *GUI) error {
|
func WithFontSize(size float64) func(g *GUI) error {
|
||||||
return func(g *GUI) error {
|
return func(g *GUI) error {
|
||||||
g.fontManager.SetSize(size)
|
g.fontManager.SetSize(size)
|
||||||
|
|
|
@ -25,8 +25,6 @@ type Buffer struct {
|
||||||
charsets []*map[rune]rune // array of 2 charsets, nil means ASCII (no conversion)
|
charsets []*map[rune]rune // array of 2 charsets, nil means ASCII (no conversion)
|
||||||
currentCharset int // active charset index in charsets array, valid values are 0 or 1
|
currentCharset int // active charset index in charsets array, valid values are 0 or 1
|
||||||
modes Modes
|
modes Modes
|
||||||
mouseMode MouseMode
|
|
||||||
mouseExtMode MouseExtMode
|
|
||||||
selectionStart *Position
|
selectionStart *Position
|
||||||
selectionEnd *Position
|
selectionEnd *Position
|
||||||
highlightStart *Position
|
highlightStart *Position
|
||||||
|
@ -80,14 +78,6 @@ func (buffer *Buffer) IsCursorVisible() bool {
|
||||||
return buffer.modes.ShowCursor
|
return buffer.modes.ShowCursor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (buffer *Buffer) GetMouseMode() MouseMode {
|
|
||||||
return buffer.mouseMode
|
|
||||||
}
|
|
||||||
|
|
||||||
func (buffer *Buffer) GetMouseExtMode() MouseExtMode {
|
|
||||||
return buffer.mouseExtMode
|
|
||||||
}
|
|
||||||
|
|
||||||
func (buffer *Buffer) IsApplicationCursorKeysModeEnabled() bool {
|
func (buffer *Buffer) IsApplicationCursorKeysModeEnabled() bool {
|
||||||
return buffer.modes.ApplicationCursorKeys
|
return buffer.modes.ApplicationCursorKeys
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,11 +717,9 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
|
||||||
t.activeBuffer.modes.AutoWrap = enabled
|
t.activeBuffer.modes.AutoWrap = enabled
|
||||||
case "?9":
|
case "?9":
|
||||||
if enabled {
|
if enabled {
|
||||||
//terminal.logger.Infof("Turning on X10 mouse mode")
|
t.mouseMode = (MouseModeX10)
|
||||||
t.activeBuffer.mouseMode = (MouseModeX10)
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off X10 mouse mode")
|
t.mouseMode = (MouseModeNone)
|
||||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
|
||||||
}
|
}
|
||||||
case "?12", "?13":
|
case "?12", "?13":
|
||||||
t.activeBuffer.modes.BlinkingCursor = enabled
|
t.activeBuffer.modes.BlinkingCursor = enabled
|
||||||
|
@ -737,46 +735,40 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
|
||||||
// enable mouse tracking
|
// enable mouse tracking
|
||||||
// 1000 refers to ext mode for extended mouse click area - otherwise only x <= 255-31
|
// 1000 refers to ext mode for extended mouse click area - otherwise only x <= 255-31
|
||||||
if enabled {
|
if enabled {
|
||||||
t.activeBuffer.mouseMode = (MouseModeVT200)
|
t.mouseMode = (MouseModeVT200)
|
||||||
} else {
|
} else {
|
||||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
t.mouseMode = (MouseModeNone)
|
||||||
}
|
}
|
||||||
case "?1002":
|
case "?1002":
|
||||||
if enabled {
|
if enabled {
|
||||||
//terminal.logger.Infof("Turning on Button Event mouse mode")
|
t.mouseMode = (MouseModeButtonEvent)
|
||||||
t.activeBuffer.mouseMode = (MouseModeButtonEvent)
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off Button Event mouse mode")
|
t.mouseMode = (MouseModeNone)
|
||||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
|
||||||
}
|
}
|
||||||
case "?1003":
|
case "?1003":
|
||||||
if enabled {
|
if enabled {
|
||||||
t.activeBuffer.mouseMode = MouseModeAnyEvent
|
t.mouseMode = MouseModeAnyEvent
|
||||||
} else {
|
} else {
|
||||||
t.activeBuffer.mouseMode = MouseModeNone
|
t.mouseMode = MouseModeNone
|
||||||
}
|
}
|
||||||
case "?1005":
|
case "?1005":
|
||||||
if enabled {
|
if enabled {
|
||||||
t.activeBuffer.mouseExtMode = MouseExtUTF
|
t.mouseExtMode = MouseExtUTF
|
||||||
} else {
|
} else {
|
||||||
t.activeBuffer.mouseExtMode = MouseExtNone
|
t.mouseExtMode = MouseExtNone
|
||||||
}
|
}
|
||||||
|
|
||||||
case "?1006":
|
case "?1006":
|
||||||
if enabled {
|
if enabled {
|
||||||
//.logger.Infof("Turning on SGR ext mouse mode")
|
t.mouseExtMode = MouseExtSGR
|
||||||
t.activeBuffer.mouseExtMode = MouseExtSGR
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off SGR ext mouse mode")
|
t.mouseExtMode = (MouseExtNone)
|
||||||
t.activeBuffer.mouseExtMode = (MouseExtNone)
|
|
||||||
}
|
}
|
||||||
case "?1015":
|
case "?1015":
|
||||||
if enabled {
|
if enabled {
|
||||||
//terminal.logger.Infof("Turning on URXVT ext mouse mode")
|
t.mouseExtMode = (MouseExtURXVT)
|
||||||
t.activeBuffer.mouseExtMode = (MouseExtURXVT)
|
|
||||||
} else {
|
} else {
|
||||||
//terminal.logger.Infof("Turning off URXVT ext mouse mode")
|
t.mouseExtMode = (MouseExtNone)
|
||||||
t.activeBuffer.mouseExtMode = (MouseExtNone)
|
|
||||||
}
|
}
|
||||||
case "?1048":
|
case "?1048":
|
||||||
if enabled {
|
if enabled {
|
||||||
|
|
|
@ -27,6 +27,8 @@ type Terminal struct {
|
||||||
closeChan chan struct{}
|
closeChan chan struct{}
|
||||||
buffers []*Buffer
|
buffers []*Buffer
|
||||||
activeBuffer *Buffer
|
activeBuffer *Buffer
|
||||||
|
mouseMode MouseMode
|
||||||
|
mouseExtMode MouseExtMode
|
||||||
logFile *os.File
|
logFile *os.File
|
||||||
theme *Theme
|
theme *Theme
|
||||||
running bool
|
running bool
|
||||||
|
@ -157,11 +159,14 @@ func (t *Terminal) Run(updateChan chan struct{}, rows uint16, cols uint16) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set stdin in raw mode.
|
// Set stdin in raw mode.
|
||||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
|
||||||
if err != nil {
|
if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) {
|
||||||
t.windowManipulator.ReportError(err)
|
oldState, err := term.MakeRaw(fd)
|
||||||
|
if err != nil {
|
||||||
|
t.windowManipulator.ReportError(err)
|
||||||
|
}
|
||||||
|
defer func() { _ = term.Restore(fd, oldState) }() // Best effort.
|
||||||
}
|
}
|
||||||
defer func() { _ = term.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
|
|
||||||
|
|
||||||
go t.process()
|
go t.process()
|
||||||
|
|
||||||
|
@ -282,6 +287,14 @@ func (t *Terminal) switchBuffer(index uint8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Terminal) GetMouseMode() MouseMode {
|
||||||
|
return t.mouseMode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Terminal) GetMouseExtMode() MouseExtMode {
|
||||||
|
return t.mouseExtMode
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Terminal) GetActiveBuffer() *Buffer {
|
func (t *Terminal) GetActiveBuffer() *Buffer {
|
||||||
return t.activeBuffer
|
return t.activeBuffer
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Theme struct {
|
type Theme struct {
|
||||||
alpha uint8
|
|
||||||
colourMap map[Colour]color.Color
|
colourMap map[Colour]color.Color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ func (t *Theme) ColourFrom4Bit(code uint8) color.Color {
|
||||||
func (t *Theme) DefaultBackground() color.Color {
|
func (t *Theme) DefaultBackground() color.Color {
|
||||||
c, ok := t.colourMap[ColourBackground]
|
c, ok := t.colourMap[ColourBackground]
|
||||||
if !ok {
|
if !ok {
|
||||||
return color.RGBA{0, 0, 0, t.alpha}
|
return color.RGBA{0, 0, 0, 0xff}
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -95,7 +94,7 @@ func (t *Theme) DefaultBackground() color.Color {
|
||||||
func (t *Theme) DefaultForeground() color.Color {
|
func (t *Theme) DefaultForeground() color.Color {
|
||||||
c, ok := t.colourMap[ColourForeground]
|
c, ok := t.colourMap[ColourForeground]
|
||||||
if !ok {
|
if !ok {
|
||||||
return color.RGBA{255, 255, 255, t.alpha}
|
return color.RGBA{255, 255, 255, 0xff}
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -103,7 +102,7 @@ func (t *Theme) DefaultForeground() color.Color {
|
||||||
func (t *Theme) SelectionBackground() color.Color {
|
func (t *Theme) SelectionBackground() color.Color {
|
||||||
c, ok := t.colourMap[ColourSelectionBackground]
|
c, ok := t.colourMap[ColourSelectionBackground]
|
||||||
if !ok {
|
if !ok {
|
||||||
return color.RGBA{0, 0, 0, t.alpha}
|
return color.RGBA{0, 0, 0, 0xff}
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -111,7 +110,7 @@ func (t *Theme) SelectionBackground() color.Color {
|
||||||
func (t *Theme) SelectionForeground() color.Color {
|
func (t *Theme) SelectionForeground() color.Color {
|
||||||
c, ok := t.colourMap[ColourSelectionForeground]
|
c, ok := t.colourMap[ColourSelectionForeground]
|
||||||
if !ok {
|
if !ok {
|
||||||
return color.RGBA{255, 255, 255, t.alpha}
|
return color.RGBA{255, 255, 255, 0xff}
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -119,7 +118,7 @@ func (t *Theme) SelectionForeground() color.Color {
|
||||||
func (t *Theme) CursorBackground() color.Color {
|
func (t *Theme) CursorBackground() color.Color {
|
||||||
c, ok := t.colourMap[ColourCursorBackground]
|
c, ok := t.colourMap[ColourCursorBackground]
|
||||||
if !ok {
|
if !ok {
|
||||||
return color.RGBA{255, 255, 255, t.alpha}
|
return color.RGBA{255, 255, 255, 0xff}
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -127,7 +126,7 @@ func (t *Theme) CursorBackground() color.Color {
|
||||||
func (t *Theme) CursorForeground() color.Color {
|
func (t *Theme) CursorForeground() color.Color {
|
||||||
c, ok := t.colourMap[ColourCursorForeground]
|
c, ok := t.colourMap[ColourCursorForeground]
|
||||||
if !ok {
|
if !ok {
|
||||||
return color.RGBA{0, 0, 0, t.alpha}
|
return color.RGBA{0, 0, 0, 0xff}
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -149,12 +148,12 @@ func (t *Theme) ColourFrom8Bit(n string) (color.Color, error) {
|
||||||
R: byte(c),
|
R: byte(c),
|
||||||
G: byte(c),
|
G: byte(c),
|
||||||
B: byte(c),
|
B: byte(c),
|
||||||
A: t.alpha,
|
A: 0xff,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var colour color.RGBA
|
var colour color.RGBA
|
||||||
colour.A = t.alpha
|
colour.A = 0xff
|
||||||
indexR := ((index - 16) / 36)
|
indexR := ((index - 16) / 36)
|
||||||
if indexR > 0 {
|
if indexR > 0 {
|
||||||
colour.R = uint8(55 + indexR*40)
|
colour.R = uint8(55 + indexR*40)
|
||||||
|
@ -188,7 +187,7 @@ func (t *Theme) ColourFrom24Bit(r, g, b string) (color.Color, error) {
|
||||||
R: byte(ri),
|
R: byte(ri),
|
||||||
G: byte(gi),
|
G: byte(gi),
|
||||||
B: byte(bi),
|
B: byte(bi),
|
||||||
A: t.alpha,
|
A: 0xff,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ type ThemeFactory struct {
|
||||||
func NewThemeFactory() *ThemeFactory {
|
func NewThemeFactory() *ThemeFactory {
|
||||||
return &ThemeFactory{
|
return &ThemeFactory{
|
||||||
theme: &Theme{
|
theme: &Theme{
|
||||||
alpha: 0xff,
|
|
||||||
colourMap: map[Colour]color.Color{},
|
colourMap: map[Colour]color.Color{},
|
||||||
},
|
},
|
||||||
colourMap: make(map[Colour]color.Color),
|
colourMap: make(map[Colour]color.Color),
|
||||||
|
@ -24,17 +23,12 @@ func (t *ThemeFactory) Build() *Theme {
|
||||||
R: uint8(r / 0xff),
|
R: uint8(r / 0xff),
|
||||||
G: uint8(g / 0xff),
|
G: uint8(g / 0xff),
|
||||||
B: uint8(b / 0xff),
|
B: uint8(b / 0xff),
|
||||||
A: t.theme.alpha,
|
A: 0xff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t.theme
|
return t.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ThemeFactory) WithOpacity(opacity float64) *ThemeFactory {
|
|
||||||
t.theme.alpha = uint8(0xff * opacity)
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ThemeFactory) WithColour(key Colour, colour color.Color) *ThemeFactory {
|
func (t *ThemeFactory) WithColour(key Colour, colour color.Color) *ThemeFactory {
|
||||||
t.colourMap[key] = colour
|
t.colourMap[key] = colour
|
||||||
return t
|
return t
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Determining platform..."
|
||||||
|
platform=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
|
echo "Finding latest release..."
|
||||||
|
asset=$(curl --silent https://api.github.com/repos/liamg/darktile/releases/latest | jq -r ".assets[] | select(.name | contains(\"${platform}\")) | .url")
|
||||||
|
echo "Downloading latest release for your platform..."
|
||||||
|
curl -s -L -H "Accept: application/octet-stream" "${asset}" --output /tmp/darktile
|
||||||
|
echo "Installing darktile..."
|
||||||
|
chmod +x /tmp/darktile
|
||||||
|
installdir="${HOME}/bin/"
|
||||||
|
if [ "$EUID" -eq 0 ]; then
|
||||||
|
installdir="/usr/local/bin/"
|
||||||
|
fi
|
||||||
|
mkdir -p $installdir
|
||||||
|
mv /tmp/darktile "${installdir}/darktile"
|
||||||
|
which darktile &> /dev/null || (echo "Please add ${installdir} to your PATH to complete installation!" && exit 1)
|
||||||
|
echo "Installation complete!"
|
Loading…
Reference in New Issue