erm
This commit is contained in:
parent
c7953f8ee1
commit
7530d1bf0a
|
@ -1 +0,0 @@
|
||||||
github: liamg
|
|
|
@ -1,28 +0,0 @@
|
||||||
name: Release
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- v*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Releasing Darktile
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '^1.17'
|
|
||||||
- run: go version
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
args: release --rm-dist
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
@ -1,21 +0,0 @@
|
||||||
on: [push, pull_request]
|
|
||||||
name: Test
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go-version: [1.17.x]
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install xorg-dev libgl1-mesa-dev
|
|
||||||
DISPLAY=:0 go test -mod=vendor ./...
|
|
|
@ -6,12 +6,12 @@ import (
|
||||||
"image"
|
"image"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
config2 "tuxpa.in/t/erm/app/darktile/config"
|
||||||
|
gui2 "tuxpa.in/t/erm/app/darktile/gui"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/hinters"
|
||||||
|
termutil2 "tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/version"
|
||||||
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/config"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/gui"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/hinters"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/version"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ var rootCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
var startupErrors []error
|
var startupErrors []error
|
||||||
var fileNotFound *config.ErrorFileNotFound
|
var fileNotFound *config2.ErrorFileNotFound
|
||||||
|
|
||||||
conf, err := config.LoadConfig()
|
conf, err := config2.LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.As(err, &fileNotFound) {
|
if !errors.As(err, &fileNotFound) {
|
||||||
startupErrors = append(startupErrors, err)
|
startupErrors = append(startupErrors, err)
|
||||||
}
|
}
|
||||||
conf = config.DefaultConfig()
|
conf = config2.DefaultConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
if rewriteConfig {
|
if rewriteConfig {
|
||||||
|
@ -53,48 +53,48 @@ var rootCmd = &cobra.Command{
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var theme *termutil.Theme
|
var theme *termutil2.Theme
|
||||||
|
|
||||||
if themePath != "" {
|
if themePath != "" {
|
||||||
theme, err = config.LoadThemeFromPath(conf, themePath)
|
theme, err = config2.LoadThemeFromPath(conf, themePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to load theme: %s", err)
|
return fmt.Errorf("failed to load theme: %s", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
theme, err = config.LoadTheme(conf)
|
theme, err = config2.LoadTheme(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.As(err, &fileNotFound) {
|
if !errors.As(err, &fileNotFound) {
|
||||||
startupErrors = append(startupErrors, err)
|
startupErrors = append(startupErrors, err)
|
||||||
}
|
}
|
||||||
theme, err = config.DefaultTheme(conf)
|
theme, err = config2.DefaultTheme(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to load default theme: %w", err)
|
return fmt.Errorf("failed to load default theme: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
termOpts := []termutil.Option{
|
termOpts := []termutil2.Option{
|
||||||
termutil.WithTheme(theme),
|
termutil2.WithTheme(theme),
|
||||||
}
|
}
|
||||||
|
|
||||||
if debugFile != "" {
|
if debugFile != "" {
|
||||||
termOpts = append(termOpts, termutil.WithLogFile(debugFile))
|
termOpts = append(termOpts, termutil2.WithLogFile(debugFile))
|
||||||
}
|
}
|
||||||
if shell != "" {
|
if shell != "" {
|
||||||
termOpts = append(termOpts, termutil.WithShell(shell))
|
termOpts = append(termOpts, termutil2.WithShell(shell))
|
||||||
}
|
}
|
||||||
if initialCommand != "" {
|
if initialCommand != "" {
|
||||||
termOpts = append(termOpts, termutil.WithInitialCommand(initialCommand))
|
termOpts = append(termOpts, termutil2.WithInitialCommand(initialCommand))
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal := termutil.New(termOpts...)
|
terminal := termutil2.New(termOpts...)
|
||||||
|
|
||||||
options := []gui.Option{
|
options := []gui2.Option{
|
||||||
gui.WithFontDPI(conf.Font.DPI),
|
gui2.WithFontDPI(conf.Font.DPI),
|
||||||
gui.WithFontSize(conf.Font.Size),
|
gui2.WithFontSize(conf.Font.Size),
|
||||||
gui.WithFontFamily(conf.Font.Family),
|
gui2.WithFontFamily(conf.Font.Family),
|
||||||
gui.WithOpacity(conf.Opacity),
|
gui2.WithOpacity(conf.Opacity),
|
||||||
gui.WithLigatures(conf.Font.Ligatures),
|
gui2.WithLigatures(conf.Font.Ligatures),
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.Cursor.Image != "" {
|
if conf.Cursor.Image != "" {
|
||||||
|
@ -102,12 +102,12 @@ var rootCmd = &cobra.Command{
|
||||||
if err != nil {
|
if err != nil {
|
||||||
startupErrors = append(startupErrors, err)
|
startupErrors = append(startupErrors, err)
|
||||||
} else {
|
} else {
|
||||||
options = append(options, gui.WithCursorImage(img))
|
options = append(options, gui2.WithCursorImage(img))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if screenshotAfterMS > 0 {
|
if screenshotAfterMS > 0 {
|
||||||
options = append(options, gui.WithStartupFunc(func(g *gui.GUI) {
|
options = append(options, gui2.WithStartupFunc(func(g *gui2.GUI) {
|
||||||
<-time.After(time.Duration(screenshotAfterMS) * time.Millisecond)
|
<-time.After(time.Duration(screenshotAfterMS) * time.Millisecond)
|
||||||
g.RequestScreenshot(screenshotFilename)
|
g.RequestScreenshot(screenshotFilename)
|
||||||
}))
|
}))
|
||||||
|
@ -115,10 +115,10 @@ var rootCmd = &cobra.Command{
|
||||||
|
|
||||||
// load all hinters
|
// load all hinters
|
||||||
for _, hinter := range hinters.All() {
|
for _, hinter := range hinters.All() {
|
||||||
options = append(options, gui.WithHinter(hinter))
|
options = append(options, gui2.WithHinter(hinter))
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := gui.New(terminal, options...)
|
g, err := gui2.New(terminal, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
|
@ -4,8 +4,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
termutil2 "tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultConfig = Config{
|
var defaultConfig = Config{
|
||||||
|
@ -48,11 +47,11 @@ func DefaultConfig() *Config {
|
||||||
return &copiedConf
|
return &copiedConf
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultTheme(conf *Config) (*termutil.Theme, error) {
|
func DefaultTheme(conf *Config) (*termutil2.Theme, error) {
|
||||||
return loadThemeFromConf(conf, &defaultTheme)
|
return loadThemeFromConf(conf, &defaultTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadTheme(conf *Config) (*termutil.Theme, error) {
|
func LoadTheme(conf *Config) (*termutil2.Theme, error) {
|
||||||
|
|
||||||
themeConf, err := loadTheme("")
|
themeConf, err := loadTheme("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -62,7 +61,7 @@ func LoadTheme(conf *Config) (*termutil.Theme, error) {
|
||||||
return loadThemeFromConf(conf, themeConf)
|
return loadThemeFromConf(conf, themeConf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadThemeFromPath(conf *Config, path string) (*termutil.Theme, error) {
|
func LoadThemeFromPath(conf *Config, path string) (*termutil2.Theme, error) {
|
||||||
|
|
||||||
themeConf, err := loadTheme(path)
|
themeConf, err := loadTheme(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,33 +71,33 @@ func LoadThemeFromPath(conf *Config, path string) (*termutil.Theme, error) {
|
||||||
return loadThemeFromConf(conf, themeConf)
|
return loadThemeFromConf(conf, themeConf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadThemeFromConf(conf *Config, themeConf *Theme) (*termutil.Theme, error) {
|
func loadThemeFromConf(conf *Config, themeConf *Theme) (*termutil2.Theme, error) {
|
||||||
|
|
||||||
factory := termutil.NewThemeFactory()
|
factory := termutil2.NewThemeFactory()
|
||||||
|
|
||||||
colours := map[termutil.Colour]string{
|
colours := map[termutil2.Colour]string{
|
||||||
termutil.ColourBlack: themeConf.Black,
|
termutil2.ColourBlack: themeConf.Black,
|
||||||
termutil.ColourRed: themeConf.Red,
|
termutil2.ColourRed: themeConf.Red,
|
||||||
termutil.ColourGreen: themeConf.Green,
|
termutil2.ColourGreen: themeConf.Green,
|
||||||
termutil.ColourYellow: themeConf.Yellow,
|
termutil2.ColourYellow: themeConf.Yellow,
|
||||||
termutil.ColourBlue: themeConf.Blue,
|
termutil2.ColourBlue: themeConf.Blue,
|
||||||
termutil.ColourMagenta: themeConf.Magenta,
|
termutil2.ColourMagenta: themeConf.Magenta,
|
||||||
termutil.ColourCyan: themeConf.Cyan,
|
termutil2.ColourCyan: themeConf.Cyan,
|
||||||
termutil.ColourWhite: themeConf.White,
|
termutil2.ColourWhite: themeConf.White,
|
||||||
termutil.ColourBrightBlack: themeConf.BrightBlack,
|
termutil2.ColourBrightBlack: themeConf.BrightBlack,
|
||||||
termutil.ColourBrightRed: themeConf.BrightRed,
|
termutil2.ColourBrightRed: themeConf.BrightRed,
|
||||||
termutil.ColourBrightGreen: themeConf.BrightGreen,
|
termutil2.ColourBrightGreen: themeConf.BrightGreen,
|
||||||
termutil.ColourBrightYellow: themeConf.BrightYellow,
|
termutil2.ColourBrightYellow: themeConf.BrightYellow,
|
||||||
termutil.ColourBrightBlue: themeConf.BrightBlue,
|
termutil2.ColourBrightBlue: themeConf.BrightBlue,
|
||||||
termutil.ColourBrightMagenta: themeConf.BrightMagenta,
|
termutil2.ColourBrightMagenta: themeConf.BrightMagenta,
|
||||||
termutil.ColourBrightCyan: themeConf.BrightCyan,
|
termutil2.ColourBrightCyan: themeConf.BrightCyan,
|
||||||
termutil.ColourBrightWhite: themeConf.BrightWhite,
|
termutil2.ColourBrightWhite: themeConf.BrightWhite,
|
||||||
termutil.ColourBackground: themeConf.Background,
|
termutil2.ColourBackground: themeConf.Background,
|
||||||
termutil.ColourForeground: themeConf.Foreground,
|
termutil2.ColourForeground: themeConf.Foreground,
|
||||||
termutil.ColourSelectionBackground: themeConf.SelectionBackground,
|
termutil2.ColourSelectionBackground: themeConf.SelectionBackground,
|
||||||
termutil.ColourSelectionForeground: themeConf.SelectionForeground,
|
termutil2.ColourSelectionForeground: themeConf.SelectionForeground,
|
||||||
termutil.ColourCursorForeground: themeConf.CursorForeground,
|
termutil2.ColourCursorForeground: themeConf.CursorForeground,
|
||||||
termutil.ColourCursorBackground: themeConf.CursorBackground,
|
termutil2.ColourCursorBackground: themeConf.CursorBackground,
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, colHex := range colours {
|
for key, colHex := range colours {
|
|
@ -5,8 +5,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Theme struct {
|
type Theme struct {
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/packed"
|
|
||||||
"github.com/liamg/fontinfo"
|
"github.com/liamg/fontinfo"
|
||||||
"golang.org/x/image/font"
|
"golang.org/x/image/font"
|
||||||
"golang.org/x/image/font/opentype"
|
"golang.org/x/image/font/opentype"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/packed"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Style uint8
|
type Style uint8
|
|
@ -1,14 +1,12 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"tuxpa.in/t/erm/app/darktile/gui/render"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/gui/render"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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) {
|
||||||
render.
|
render.New(screen, g.terminal, g.fontManager, g.popupMessages, g.opacity, g.enableLigatures, g.cursorImage).
|
||||||
New(screen, g.terminal, g.fontManager, g.popupMessages, g.opacity, g.enableLigatures, g.cursorImage).
|
|
||||||
Draw()
|
Draw()
|
||||||
|
|
||||||
if g.screenshotRequested {
|
if g.screenshotRequested {
|
|
@ -7,13 +7,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/font"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/font"
|
"tuxpa.in/t/erm/app/darktile/gui/popup"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/gui/popup"
|
"tuxpa.in/t/erm/app/darktile/hinters"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/hinters"
|
termutil2 "tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -26,12 +23,12 @@ type GUI struct {
|
||||||
mouseStateMiddle MouseState
|
mouseStateMiddle MouseState
|
||||||
mouseDrag bool
|
mouseDrag bool
|
||||||
size image.Point // pixels
|
size image.Point // pixels
|
||||||
terminal *termutil.Terminal
|
terminal *termutil2.Terminal
|
||||||
updateChan chan struct{}
|
updateChan chan struct{}
|
||||||
lastClick time.Time
|
lastClick time.Time
|
||||||
clickCount int
|
clickCount int
|
||||||
fontManager *font.Manager
|
fontManager *font.Manager
|
||||||
mousePos termutil.Position
|
mousePos termutil2.Position
|
||||||
hinters []hinters.Hinter
|
hinters []hinters.Hinter
|
||||||
activeHinter int
|
activeHinter int
|
||||||
popupMessages []popup.Message
|
popupMessages []popup.Message
|
||||||
|
@ -51,7 +48,7 @@ const (
|
||||||
MouseStatePressed
|
MouseStatePressed
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(terminal *termutil.Terminal, options ...Option) (*GUI, error) {
|
func New(terminal *termutil2.Terminal, options ...Option) (*GUI, error) {
|
||||||
|
|
||||||
g := &GUI{
|
g := &GUI{
|
||||||
terminal: terminal,
|
terminal: terminal,
|
||||||
|
@ -115,14 +112,14 @@ func (g *GUI) CellSize() image.Point {
|
||||||
return g.fontManager.CharSize()
|
return g.fontManager.CharSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GUI) Highlight(start termutil.Position, end termutil.Position, label string, img image.Image) {
|
func (g *GUI) Highlight(start termutil2.Position, end termutil2.Position, label string, img image.Image) {
|
||||||
|
|
||||||
if label == "" && img == nil {
|
if label == "" && img == nil {
|
||||||
g.terminal.GetActiveBuffer().Highlight(start, end, nil)
|
g.terminal.GetActiveBuffer().Highlight(start, end, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
annotation := &termutil.Annotation{
|
annotation := &termutil2.Annotation{
|
||||||
Text: label,
|
Text: label,
|
||||||
Image: img,
|
Image: img,
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/d-tsuji/clipboard"
|
"github.com/d-tsuji/clipboard"
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var modifiableKeys = map[ebiten.Key]uint8{
|
var modifiableKeys = map[ebiten.Key]uint8{
|
|
@ -3,8 +3,6 @@ package gui
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
|
@ -1,8 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WindowManipulator struct {
|
type WindowManipulator struct {
|
|
@ -3,10 +3,8 @@ package gui
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/hinters"
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
termutil2 "tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/hinters"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// time allowed between mouse clicks to chain them into e.g. double-click
|
// time allowed between mouse clicks to chain them into e.g. double-click
|
||||||
|
@ -33,7 +31,7 @@ func (g *GUI) handleMouse() error {
|
||||||
if col >= 0 && col < int(g.terminal.GetActiveBuffer().ViewWidth()) && line >= 0 && line < int(g.terminal.GetActiveBuffer().ViewHeight()) {
|
if col >= 0 && col < int(g.terminal.GetActiveBuffer().ViewWidth()) && line >= 0 && line < int(g.terminal.GetActiveBuffer().ViewHeight()) {
|
||||||
// mouse moved!
|
// mouse moved!
|
||||||
moved = true
|
moved = true
|
||||||
g.mousePos = termutil.Position{
|
g.mousePos = termutil2.Position{
|
||||||
Col: uint16(col),
|
Col: uint16(col),
|
||||||
Line: uint64(line),
|
Line: uint64(line),
|
||||||
}
|
}
|
||||||
|
@ -86,7 +84,7 @@ func (g *GUI) handleMouse() error {
|
||||||
if g.mouseDrag {
|
if g.mouseDrag {
|
||||||
|
|
||||||
// update selection end
|
// update selection end
|
||||||
g.terminal.GetActiveBuffer().SetSelectionEnd(termutil.Position{
|
g.terminal.GetActiveBuffer().SetSelectionEnd(termutil2.Position{
|
||||||
Line: uint64(line),
|
Line: uint64(line),
|
||||||
Col: uint16(col),
|
Col: uint16(col),
|
||||||
})
|
})
|
||||||
|
@ -116,7 +114,7 @@ func (g *GUI) handleMouse() error {
|
||||||
col := x / g.fontManager.CharSize().X
|
col := x / g.fontManager.CharSize().X
|
||||||
line := y / g.fontManager.CharSize().Y
|
line := y / g.fontManager.CharSize().Y
|
||||||
|
|
||||||
g.terminal.GetActiveBuffer().SetSelectionStart(termutil.Position{
|
g.terminal.GetActiveBuffer().SetSelectionStart(termutil2.Position{
|
||||||
Line: uint64(line),
|
Line: uint64(line),
|
||||||
Col: uint16(col),
|
Col: uint16(col),
|
||||||
})
|
})
|
||||||
|
@ -142,7 +140,7 @@ func (g *GUI) clearHinters() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// mouse moved to cell (not during click + drag)
|
// mouse moved to cell (not during click + drag)
|
||||||
func (g *GUI) handleMouseMove(pos termutil.Position) error {
|
func (g *GUI) handleMouseMove(pos termutil2.Position) error {
|
||||||
|
|
||||||
// start uses raw coords
|
// start uses raw coords
|
||||||
start, _, text, index, ok := g.terminal.GetActiveBuffer().GetBoundedTextAtPosition(pos)
|
start, _, text, index, ok := g.terminal.GetActiveBuffer().GetBoundedTextAtPosition(pos)
|
||||||
|
@ -171,11 +169,11 @@ func (g *GUI) handleMouseMove(pos termutil.Position) error {
|
||||||
newEndY++
|
newEndY++
|
||||||
}
|
}
|
||||||
|
|
||||||
matchStart := termutil.Position{
|
matchStart := termutil2.Position{
|
||||||
Col: uint16(newStartX),
|
Col: uint16(newStartX),
|
||||||
Line: newStartY,
|
Line: newStartY,
|
||||||
}
|
}
|
||||||
matchEnd := termutil.Position{
|
matchEnd := termutil2.Position{
|
||||||
Col: uint16(newEndX),
|
Col: uint16(newEndX),
|
||||||
Line: newEndY,
|
Line: newEndY,
|
||||||
}
|
}
|
||||||
|
@ -223,7 +221,7 @@ func (g *GUI) handleClick(clickCount, x, y int) (bool, error) {
|
||||||
case 2: //double click
|
case 2: //double click
|
||||||
col := uint16(x / g.fontManager.CharSize().X)
|
col := uint16(x / g.fontManager.CharSize().X)
|
||||||
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(termutil2.Position{Col: col, Line: line}, wordMatcher)
|
||||||
return true, nil
|
return true, nil
|
||||||
default: // triple click (or more!)
|
default: // triple click (or more!)
|
||||||
g.terminal.GetActiveBuffer().ExtendSelectionToEntireLines()
|
g.terminal.GetActiveBuffer().ExtendSelectionToEntireLines()
|
||||||
|
@ -274,9 +272,9 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
mode := g.terminal.GetMouseMode()
|
mode := g.terminal.GetMouseMode()
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case termutil.MouseModeNone:
|
case termutil2.MouseModeNone:
|
||||||
return false
|
return false
|
||||||
case termutil.MouseModeX10:
|
case termutil2.MouseModeX10:
|
||||||
var button rune
|
var button rune
|
||||||
switch true {
|
switch true {
|
||||||
case pressedLeft:
|
case pressedLeft:
|
||||||
|
@ -291,7 +289,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
packet := fmt.Sprintf("\x1b[M%c%c%c", (rune(button + 32)), (rune(tx + 32)), (rune(ty + 32)))
|
packet := fmt.Sprintf("\x1b[M%c%c%c", (rune(button + 32)), (rune(tx + 32)), (rune(ty + 32)))
|
||||||
_ = g.terminal.WriteToPty([]byte(packet))
|
_ = g.terminal.WriteToPty([]byte(packet))
|
||||||
return true
|
return true
|
||||||
case termutil.MouseModeVT200, termutil.MouseModeButtonEvent:
|
case termutil2.MouseModeVT200, termutil2.MouseModeButtonEvent:
|
||||||
|
|
||||||
var button rune
|
var button rune
|
||||||
|
|
||||||
|
@ -305,14 +303,14 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
case pressedRight:
|
case pressedRight:
|
||||||
button = 2
|
button = 2
|
||||||
case released:
|
case released:
|
||||||
if extMode != termutil.MouseExtSGR {
|
if extMode != termutil2.MouseExtSGR {
|
||||||
button = 3
|
button = 3
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if moved && mode == termutil.MouseModeButtonEvent {
|
if moved && mode == termutil2.MouseModeButtonEvent {
|
||||||
button |= 32
|
button |= 32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +328,7 @@ func (g *GUI) handleMouseRemotely(x, y int, pressedLeft, pressedMiddle, pressedR
|
||||||
|
|
||||||
var packet string
|
var packet string
|
||||||
|
|
||||||
if extMode == termutil.MouseExtSGR {
|
if extMode == termutil2.MouseExtSGR {
|
||||||
final := 'M'
|
final := 'M'
|
||||||
if released {
|
if released {
|
||||||
final = 'm'
|
final = 'm'
|
|
@ -2,8 +2,6 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Option func(g *GUI) error
|
type Option func(g *GUI) error
|
|
@ -4,8 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"time"
|
"time"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/gui/popup"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/gui/popup"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
|
@ -3,7 +3,6 @@ package render
|
||||||
import (
|
import (
|
||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||||
"github.com/hajimehoshi/ebiten/v2/text"
|
"github.com/hajimehoshi/ebiten/v2/text"
|
||||||
)
|
)
|
|
@ -1,10 +1,9 @@
|
||||||
package render
|
package render
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||||
"github.com/hajimehoshi/ebiten/v2/text"
|
"github.com/hajimehoshi/ebiten/v2/text"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Render) drawCursor() {
|
func (r *Render) drawCursor() {
|
|
@ -2,20 +2,19 @@ package render
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/font"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/gui/popup"
|
||||||
|
termutil2 "tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/font"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/gui/popup"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
imagefont "golang.org/x/image/font"
|
imagefont "golang.org/x/image/font"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Render struct {
|
type Render struct {
|
||||||
frame *ebiten.Image
|
frame *ebiten.Image
|
||||||
screen *ebiten.Image
|
screen *ebiten.Image
|
||||||
terminal *termutil.Terminal
|
terminal *termutil2.Terminal
|
||||||
buffer *termutil.Buffer
|
buffer *termutil2.Buffer
|
||||||
theme *termutil.Theme
|
theme *termutil2.Theme
|
||||||
fontManager *font.Manager
|
fontManager *font.Manager
|
||||||
pixelWidth int
|
pixelWidth int
|
||||||
pixelHeight int
|
pixelHeight int
|
||||||
|
@ -35,7 +34,7 @@ type Font struct {
|
||||||
DotDepth int
|
DotDepth int
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(screen *ebiten.Image, terminal *termutil.Terminal, fontManager *font.Manager, popups []popup.Message, opacity float64, enableLigatures bool, cursorImage *ebiten.Image) *Render {
|
func New(screen *ebiten.Image, terminal *termutil2.Terminal, fontManager *font.Manager, popups []popup.Message, opacity float64, enableLigatures bool, cursorImage *ebiten.Image) *Render {
|
||||||
w, h := screen.Size()
|
w, h := screen.Size()
|
||||||
return &Render{
|
return &Render{
|
||||||
screen: screen,
|
screen: screen,
|
|
@ -1,7 +1,5 @@
|
||||||
package render
|
package render
|
||||||
|
|
||||||
import "github.com/hajimehoshi/ebiten/v2"
|
|
||||||
|
|
||||||
func (r *Render) drawSixels() {
|
func (r *Render) drawSixels() {
|
||||||
for _, sixel := range r.buffer.GetVisibleSixels() {
|
for _, sixel := range r.buffer.GetVisibleSixels() {
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
|
@ -2,9 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/gui/popup"
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/gui/popup"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GUI) getModifierStr() string {
|
func (g *GUI) getModifierStr() string {
|
|
@ -2,8 +2,7 @@ package hinters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HintAPI interface {
|
type HintAPI interface {
|
|
@ -2,8 +2,7 @@ package hinters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestAPI struct {
|
type TestAPI struct {
|
|
@ -3,8 +3,7 @@ package hinters
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
|
@ -2,8 +2,8 @@ package hinters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,8 +5,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
|
@ -3,8 +3,8 @@ package hinters
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,8 +6,7 @@ import (
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
|
@ -5,8 +5,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
|
@ -2,8 +2,8 @@ package hinters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
|
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
|
@ -1,9 +1,9 @@
|
||||||
package hinters
|
package hinters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
"github.com/skratchdot/open-golang/open"
|
"github.com/skratchdot/open-golang/open"
|
||||||
"mvdan.cc/xurls"
|
"mvdan.cc/xurls"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
|
@ -3,8 +3,7 @@ package hinters
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/termutil"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/termutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HinterRegistration struct {
|
type HinterRegistration struct {
|
|
@ -4,8 +4,7 @@ import (
|
||||||
"image"
|
"image"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/sixel"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/sixel"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Sixel struct {
|
type Sixel struct {
|
|
@ -2,8 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"tuxpa.in/t/erm/app/darktile/cmd"
|
||||||
"github.com/liamg/darktile/internal/app/darktile/cmd"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
3
go.mod
3
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module github.com/liamg/darktile
|
module tuxpa.in/t/erm
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ require (
|
||||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
|
||||||
mvdan.cc/xurls v1.1.0
|
mvdan.cc/xurls v1.1.0
|
||||||
sigs.k8s.io/yaml v1.1.0
|
sigs.k8s.io/yaml v1.1.0
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue