mirror of https://github.com/liamg/aminal.git
Compare commits
No commits in common. "c18b702b61d1dbd58d10584f6f784b3716a3900c" and "d99bdd3bb2510f25e76bd7d0042add99fe643559" have entirely different histories.
c18b702b61
...
d99bdd3bb2
|
@ -22,13 +22,7 @@ Install dependencies:
|
|||
- `xorg-dev`
|
||||
- `libgl1-mesa-dev`
|
||||
|
||||
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
|
||||
```
|
||||
Grab a binary from the [latest release](https://github.com/liamg/darktile/releases/latest).
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ var rootCmd = &cobra.Command{
|
|||
gui.WithFontDPI(conf.Font.DPI),
|
||||
gui.WithFontSize(conf.Font.Size),
|
||||
gui.WithFontFamily(conf.Font.Family),
|
||||
gui.WithOpacity(conf.Opacity),
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
factory := termutil.NewThemeFactory()
|
||||
factory := termutil.NewThemeFactory().WithOpacity(conf.Opacity)
|
||||
|
||||
colours := map[termutil.Colour]string{
|
||||
termutil.ColourBlack: themeConf.Black,
|
||||
|
|
|
@ -14,8 +14,6 @@ import (
|
|||
// Draw renders the terminal GUI to the ebtien window. Required to implement the ebiten interface.
|
||||
func (g *GUI) Draw(screen *ebiten.Image) {
|
||||
|
||||
tmp := ebiten.NewImage(g.size.X, g.size.Y)
|
||||
|
||||
cellSize := g.fontManager.CharSize()
|
||||
dotDepth := g.fontManager.DotDepth()
|
||||
|
||||
|
@ -38,10 +36,10 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
extraW := float64(g.size.X) - endX
|
||||
extraH := float64(g.size.Y) - endY
|
||||
if extraW > 0 {
|
||||
ebitenutil.DrawRect(tmp, endX, 0, extraW, endY, defBg)
|
||||
ebitenutil.DrawRect(screen, endX, 0, extraW, endY, defBg)
|
||||
}
|
||||
if extraH > 0 {
|
||||
ebitenutil.DrawRect(tmp, 0, endY, float64(g.size.X), extraH, defBg)
|
||||
ebitenutil.DrawRect(screen, 0, endY, float64(g.size.X), extraH, defBg)
|
||||
}
|
||||
|
||||
var inHighlight bool
|
||||
|
@ -54,7 +52,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
for y := int(buffer.ViewHeight() - 1); y >= 0; y-- {
|
||||
py := cellSize.Y * y
|
||||
|
||||
ebitenutil.DrawRect(tmp, 0, float64(py), float64(g.size.X), float64(cellSize.Y), defBg)
|
||||
ebitenutil.DrawRect(screen, 0, float64(py), float64(g.size.X), float64(cellSize.Y), defBg)
|
||||
inHighlight = false
|
||||
for x := uint16(0); x < buffer.ViewWidth(); x++ {
|
||||
cell := buffer.GetCell(x, uint16(y))
|
||||
|
@ -76,7 +74,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
colour = defBg
|
||||
}
|
||||
|
||||
ebitenutil.DrawRect(tmp, float64(px), float64(py), float64(cellSize.X), float64(cellSize.Y), colour)
|
||||
ebitenutil.DrawRect(screen, float64(px), float64(py), float64(cellSize.X), float64(cellSize.Y), colour)
|
||||
|
||||
if buffer.IsHighlighted(termutil.Position{
|
||||
Line: uint64(y),
|
||||
|
@ -108,7 +106,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
}
|
||||
|
||||
if isCursor && !ebiten.IsFocused() {
|
||||
ebitenutil.DrawRect(tmp, float64(px)+1, float64(py)+1, float64(cellSize.X)-2, float64(cellSize.Y)-2, g.terminal.Theme().DefaultBackground())
|
||||
ebitenutil.DrawRect(screen, 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++ {
|
||||
|
@ -141,13 +139,13 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
|
||||
if cell.Underline() {
|
||||
uly := float64(py + (dotDepth+cellSize.Y)/2)
|
||||
ebitenutil.DrawLine(tmp, float64(px), uly, float64(px+cellSize.X), uly, colour)
|
||||
ebitenutil.DrawLine(screen, float64(px), uly, float64(px+cellSize.X), uly, colour)
|
||||
}
|
||||
|
||||
text.Draw(tmp, string(cell.Rune().Rune), useFace, px, py+dotDepth, colour)
|
||||
text.Draw(screen, string(cell.Rune().Rune), useFace, px, py+dotDepth, colour)
|
||||
|
||||
if cell.Strikethrough() {
|
||||
ebitenutil.DrawLine(tmp, float64(px), float64(py+(cellSize.Y/2)), float64(px+cellSize.X), float64(py+(cellSize.Y/2)), colour)
|
||||
ebitenutil.DrawLine(screen, float64(px), float64(py+(cellSize.Y/2)), float64(px+cellSize.X), float64(py+(cellSize.Y/2)), colour)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -159,7 +157,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(sx, sy)
|
||||
tmp.DrawImage(
|
||||
screen.DrawImage(
|
||||
ebiten.NewImageFromImage(sixel.Sixel.Image),
|
||||
op,
|
||||
)
|
||||
|
@ -239,19 +237,19 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
}
|
||||
|
||||
// draw opaque box below and above highlighted line(s)
|
||||
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(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(tmp, 0, 0, float64(g.size.X), float64(highlightMin.Line*uint64(cellSize.Y)), color.RGBA{A: 0x80})
|
||||
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(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(screen, 0, 0, float64(g.size.X), float64(highlightMin.Line*uint64(cellSize.Y)), color.RGBA{A: 0x80})
|
||||
afterLineY := float64((1 + highlightMax.Line) * uint64(cellSize.Y))
|
||||
ebitenutil.DrawRect(tmp, 0, afterLineY, float64(g.size.X), float64(g.size.Y)-afterLineY, color.RGBA{A: 0x80})
|
||||
ebitenutil.DrawRect(screen, 0, afterLineY, float64(g.size.X), float64(g.size.Y)-afterLineY, color.RGBA{A: 0x80})
|
||||
|
||||
// annotation border
|
||||
ebitenutil.DrawRect(tmp, float64(annotationX)-padding, annotationY-padding, float64(annotationWidth)+(padding*2), annotationHeight+(padding*2), g.terminal.Theme().SelectionBackground())
|
||||
ebitenutil.DrawRect(screen, float64(annotationX)-padding, annotationY-padding, float64(annotationWidth)+(padding*2), annotationHeight+(padding*2), g.terminal.Theme().SelectionBackground())
|
||||
// annotation background
|
||||
ebitenutil.DrawRect(tmp, 1+float64(annotationX)-padding, 1+annotationY-padding, float64(annotationWidth)+(padding*2)-2, annotationHeight+(padding*2)-2, g.terminal.Theme().DefaultBackground())
|
||||
ebitenutil.DrawRect(screen, 1+float64(annotationX)-padding, 1+annotationY-padding, float64(annotationWidth)+(padding*2)-2, annotationHeight+(padding*2)-2, g.terminal.Theme().DefaultBackground())
|
||||
|
||||
// vertical line
|
||||
ebitenutil.DrawLine(tmp, lineX, float64(lineY), lineX, lineY+lineHeight, g.terminal.Theme().SelectionBackground())
|
||||
ebitenutil.DrawLine(screen, lineX, float64(lineY), lineX, lineY+lineHeight, g.terminal.Theme().SelectionBackground())
|
||||
|
||||
var tY int
|
||||
var tX int
|
||||
|
@ -261,7 +259,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(float64(annotationX), annotationY)
|
||||
tmp.DrawImage(
|
||||
screen.DrawImage(
|
||||
ebiten.NewImageFromImage(annotation.Image),
|
||||
op,
|
||||
)
|
||||
|
@ -273,7 +271,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
tX = 0
|
||||
continue
|
||||
}
|
||||
text.Draw(tmp, string(r), regularFace, annotationX+tX, int(annotationY)+dotDepth+tY, g.terminal.Theme().DefaultForeground())
|
||||
text.Draw(screen, string(r), regularFace, annotationX+tX, int(annotationY)+dotDepth+tY, g.terminal.Theme().DefaultForeground())
|
||||
tX += cellSize.X
|
||||
}
|
||||
|
||||
|
@ -300,11 +298,11 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
boxWidth = endX / 8
|
||||
}
|
||||
|
||||
ebitenutil.DrawRect(tmp, float64(msgX-1), msgY-1, boxWidth+2, boxHeight+2, msg.Foreground)
|
||||
ebitenutil.DrawRect(tmp, float64(msgX), msgY, boxWidth, boxHeight, msg.Background)
|
||||
ebitenutil.DrawRect(screen, float64(msgX-1), msgY-1, boxWidth+2, boxHeight+2, msg.Foreground)
|
||||
ebitenutil.DrawRect(screen, float64(msgX), msgY, boxWidth, boxHeight, msg.Background)
|
||||
for y, line := range lines {
|
||||
for x, r := range line {
|
||||
text.Draw(tmp, string(r), regularFace, msgX+pad+(x*cellSize.X), pad+(y*cellSize.Y)+int(msgY)+dotDepth, msg.Foreground)
|
||||
text.Draw(screen, 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)
|
||||
|
@ -312,11 +310,7 @@ func (g *GUI) Draw(screen *ebiten.Image) {
|
|||
}
|
||||
|
||||
if g.screenshotRequested {
|
||||
g.takeScreenshot(tmp)
|
||||
g.takeScreenshot(screen)
|
||||
}
|
||||
|
||||
opt := &ebiten.DrawImageOptions{}
|
||||
opt.ColorM.Scale(1, 1, 1, g.opacity)
|
||||
screen.DrawImage(tmp, opt)
|
||||
tmp.Dispose()
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ type GUI struct {
|
|||
screenshotFilename string
|
||||
startupFuncs []func(g *GUI)
|
||||
keyState *keyState
|
||||
opacity float64
|
||||
}
|
||||
|
||||
type PopupMessage struct {
|
||||
|
@ -89,7 +88,6 @@ func (g *GUI) Run() error {
|
|||
}()
|
||||
|
||||
ebiten.SetScreenTransparent(true)
|
||||
ebiten.SetScreenClearedEveryFrame(true)
|
||||
ebiten.SetWindowResizable(true)
|
||||
ebiten.SetRunnableOnUnfocused(true)
|
||||
ebiten.SetFPSMode(ebiten.FPSModeVsyncOffMinimum)
|
||||
|
|
|
@ -168,8 +168,6 @@ func (g *GUI) handleInput() error {
|
|||
return g.terminal.WriteToPty([]byte{0x09}) // tab
|
||||
|
||||
case g.keyState.RepeatPressed(ebiten.KeyEscape):
|
||||
g.terminal.GetActiveBuffer().ClearSelection()
|
||||
g.terminal.GetActiveBuffer().ClearHighlight()
|
||||
return g.terminal.WriteToPty([]byte{0x1b}) // escape
|
||||
case g.keyState.RepeatPressed(ebiten.KeyBackspace):
|
||||
if ebiten.IsKeyPressed(ebiten.KeyAlt) {
|
||||
|
|
|
@ -121,9 +121,6 @@ func (g *GUI) handleMouse() error {
|
|||
Col: uint16(col),
|
||||
})
|
||||
}
|
||||
|
||||
ebiten.ScheduleFrame()
|
||||
|
||||
} else {
|
||||
g.mouseDrag = false
|
||||
}
|
||||
|
@ -225,7 +222,7 @@ func (g *GUI) handleClick(clickCount, x, y int) (bool, error) {
|
|||
line := uint64(y / g.fontManager.CharSize().Y)
|
||||
g.terminal.GetActiveBuffer().SelectWordAt(termutil.Position{Col: col, Line: line}, wordMatcher)
|
||||
return true, nil
|
||||
default: // triple click (or more!)
|
||||
case 3: // triple click
|
||||
g.terminal.GetActiveBuffer().ExtendSelectionToEntireLines()
|
||||
return true, nil
|
||||
}
|
||||
|
@ -271,7 +268,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)
|
||||
|
||||
mode := g.terminal.GetMouseMode()
|
||||
mode := g.terminal.GetActiveBuffer().GetMouseMode()
|
||||
|
||||
switch mode {
|
||||
case termutil.MouseModeNone:
|
||||
|
@ -295,7 +292,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
|||
|
||||
var button rune
|
||||
|
||||
extMode := g.terminal.GetMouseExtMode()
|
||||
extMode := g.terminal.GetActiveBuffer().GetMouseExtMode()
|
||||
|
||||
switch true {
|
||||
case pressedLeft:
|
||||
|
|
|
@ -8,13 +8,6 @@ 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 {
|
||||
return func(g *GUI) error {
|
||||
g.fontManager.SetSize(size)
|
||||
|
|
|
@ -25,6 +25,8 @@ type Buffer struct {
|
|||
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
|
||||
modes Modes
|
||||
mouseMode MouseMode
|
||||
mouseExtMode MouseExtMode
|
||||
selectionStart *Position
|
||||
selectionEnd *Position
|
||||
highlightStart *Position
|
||||
|
@ -78,6 +80,14 @@ func (buffer *Buffer) IsCursorVisible() bool {
|
|||
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 {
|
||||
return buffer.modes.ApplicationCursorKeys
|
||||
}
|
||||
|
|
|
@ -717,9 +717,11 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
|
|||
t.activeBuffer.modes.AutoWrap = enabled
|
||||
case "?9":
|
||||
if enabled {
|
||||
t.mouseMode = (MouseModeX10)
|
||||
//terminal.logger.Infof("Turning on X10 mouse mode")
|
||||
t.activeBuffer.mouseMode = (MouseModeX10)
|
||||
} else {
|
||||
t.mouseMode = (MouseModeNone)
|
||||
//terminal.logger.Infof("Turning off X10 mouse mode")
|
||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
||||
}
|
||||
case "?12", "?13":
|
||||
t.activeBuffer.modes.BlinkingCursor = enabled
|
||||
|
@ -735,40 +737,46 @@ func (t *Terminal) csiSetMode(modes string, enabled bool) bool {
|
|||
// enable mouse tracking
|
||||
// 1000 refers to ext mode for extended mouse click area - otherwise only x <= 255-31
|
||||
if enabled {
|
||||
t.mouseMode = (MouseModeVT200)
|
||||
t.activeBuffer.mouseMode = (MouseModeVT200)
|
||||
} else {
|
||||
t.mouseMode = (MouseModeNone)
|
||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
||||
}
|
||||
case "?1002":
|
||||
if enabled {
|
||||
t.mouseMode = (MouseModeButtonEvent)
|
||||
//terminal.logger.Infof("Turning on Button Event mouse mode")
|
||||
t.activeBuffer.mouseMode = (MouseModeButtonEvent)
|
||||
} else {
|
||||
t.mouseMode = (MouseModeNone)
|
||||
//terminal.logger.Infof("Turning off Button Event mouse mode")
|
||||
t.activeBuffer.mouseMode = (MouseModeNone)
|
||||
}
|
||||
case "?1003":
|
||||
if enabled {
|
||||
t.mouseMode = MouseModeAnyEvent
|
||||
t.activeBuffer.mouseMode = MouseModeAnyEvent
|
||||
} else {
|
||||
t.mouseMode = MouseModeNone
|
||||
t.activeBuffer.mouseMode = MouseModeNone
|
||||
}
|
||||
case "?1005":
|
||||
if enabled {
|
||||
t.mouseExtMode = MouseExtUTF
|
||||
t.activeBuffer.mouseExtMode = MouseExtUTF
|
||||
} else {
|
||||
t.mouseExtMode = MouseExtNone
|
||||
t.activeBuffer.mouseExtMode = MouseExtNone
|
||||
}
|
||||
|
||||
case "?1006":
|
||||
if enabled {
|
||||
t.mouseExtMode = MouseExtSGR
|
||||
//.logger.Infof("Turning on SGR ext mouse mode")
|
||||
t.activeBuffer.mouseExtMode = MouseExtSGR
|
||||
} else {
|
||||
t.mouseExtMode = (MouseExtNone)
|
||||
//terminal.logger.Infof("Turning off SGR ext mouse mode")
|
||||
t.activeBuffer.mouseExtMode = (MouseExtNone)
|
||||
}
|
||||
case "?1015":
|
||||
if enabled {
|
||||
t.mouseExtMode = (MouseExtURXVT)
|
||||
//terminal.logger.Infof("Turning on URXVT ext mouse mode")
|
||||
t.activeBuffer.mouseExtMode = (MouseExtURXVT)
|
||||
} else {
|
||||
t.mouseExtMode = (MouseExtNone)
|
||||
//terminal.logger.Infof("Turning off URXVT ext mouse mode")
|
||||
t.activeBuffer.mouseExtMode = (MouseExtNone)
|
||||
}
|
||||
case "?1048":
|
||||
if enabled {
|
||||
|
|
|
@ -27,8 +27,6 @@ type Terminal struct {
|
|||
closeChan chan struct{}
|
||||
buffers []*Buffer
|
||||
activeBuffer *Buffer
|
||||
mouseMode MouseMode
|
||||
mouseExtMode MouseExtMode
|
||||
logFile *os.File
|
||||
theme *Theme
|
||||
running bool
|
||||
|
@ -159,14 +157,11 @@ func (t *Terminal) Run(updateChan chan struct{}, rows uint16, cols uint16) error
|
|||
}
|
||||
|
||||
// Set stdin in raw mode.
|
||||
|
||||
if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) {
|
||||
oldState, err := term.MakeRaw(fd)
|
||||
if err != nil {
|
||||
t.windowManipulator.ReportError(err)
|
||||
}
|
||||
defer func() { _ = term.Restore(fd, oldState) }() // Best effort.
|
||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
t.windowManipulator.ReportError(err)
|
||||
}
|
||||
defer func() { _ = term.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
|
||||
|
||||
go t.process()
|
||||
|
||||
|
@ -287,14 +282,6 @@ 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 {
|
||||
return t.activeBuffer
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ const (
|
|||
)
|
||||
|
||||
type Theme struct {
|
||||
alpha uint8
|
||||
colourMap map[Colour]color.Color
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ func (t *Theme) ColourFrom4Bit(code uint8) color.Color {
|
|||
func (t *Theme) DefaultBackground() color.Color {
|
||||
c, ok := t.colourMap[ColourBackground]
|
||||
if !ok {
|
||||
return color.RGBA{0, 0, 0, 0xff}
|
||||
return color.RGBA{0, 0, 0, t.alpha}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ func (t *Theme) DefaultBackground() color.Color {
|
|||
func (t *Theme) DefaultForeground() color.Color {
|
||||
c, ok := t.colourMap[ColourForeground]
|
||||
if !ok {
|
||||
return color.RGBA{255, 255, 255, 0xff}
|
||||
return color.RGBA{255, 255, 255, t.alpha}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ func (t *Theme) DefaultForeground() color.Color {
|
|||
func (t *Theme) SelectionBackground() color.Color {
|
||||
c, ok := t.colourMap[ColourSelectionBackground]
|
||||
if !ok {
|
||||
return color.RGBA{0, 0, 0, 0xff}
|
||||
return color.RGBA{0, 0, 0, t.alpha}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -110,7 +111,7 @@ func (t *Theme) SelectionBackground() color.Color {
|
|||
func (t *Theme) SelectionForeground() color.Color {
|
||||
c, ok := t.colourMap[ColourSelectionForeground]
|
||||
if !ok {
|
||||
return color.RGBA{255, 255, 255, 0xff}
|
||||
return color.RGBA{255, 255, 255, t.alpha}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -118,7 +119,7 @@ func (t *Theme) SelectionForeground() color.Color {
|
|||
func (t *Theme) CursorBackground() color.Color {
|
||||
c, ok := t.colourMap[ColourCursorBackground]
|
||||
if !ok {
|
||||
return color.RGBA{255, 255, 255, 0xff}
|
||||
return color.RGBA{255, 255, 255, t.alpha}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ func (t *Theme) CursorBackground() color.Color {
|
|||
func (t *Theme) CursorForeground() color.Color {
|
||||
c, ok := t.colourMap[ColourCursorForeground]
|
||||
if !ok {
|
||||
return color.RGBA{0, 0, 0, 0xff}
|
||||
return color.RGBA{0, 0, 0, t.alpha}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
@ -148,12 +149,12 @@ func (t *Theme) ColourFrom8Bit(n string) (color.Color, error) {
|
|||
R: byte(c),
|
||||
G: byte(c),
|
||||
B: byte(c),
|
||||
A: 0xff,
|
||||
A: t.alpha,
|
||||
}, nil
|
||||
}
|
||||
|
||||
var colour color.RGBA
|
||||
colour.A = 0xff
|
||||
colour.A = t.alpha
|
||||
indexR := ((index - 16) / 36)
|
||||
if indexR > 0 {
|
||||
colour.R = uint8(55 + indexR*40)
|
||||
|
@ -187,7 +188,7 @@ func (t *Theme) ColourFrom24Bit(r, g, b string) (color.Color, error) {
|
|||
R: byte(ri),
|
||||
G: byte(gi),
|
||||
B: byte(bi),
|
||||
A: 0xff,
|
||||
A: t.alpha,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ type ThemeFactory struct {
|
|||
func NewThemeFactory() *ThemeFactory {
|
||||
return &ThemeFactory{
|
||||
theme: &Theme{
|
||||
alpha: 0xff,
|
||||
colourMap: map[Colour]color.Color{},
|
||||
},
|
||||
colourMap: make(map[Colour]color.Color),
|
||||
|
@ -23,12 +24,17 @@ func (t *ThemeFactory) Build() *Theme {
|
|||
R: uint8(r / 0xff),
|
||||
G: uint8(g / 0xff),
|
||||
B: uint8(b / 0xff),
|
||||
A: 0xff,
|
||||
A: t.theme.alpha,
|
||||
}
|
||||
}
|
||||
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 {
|
||||
t.colourMap[key] = colour
|
||||
return t
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
#!/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