This commit is contained in:
Felix Angell 2018-04-21 19:50:31 +01:00
parent a669134873
commit b654a4918d
6 changed files with 25 additions and 18 deletions

View File

@ -2,10 +2,10 @@ package cfg
import (
"errors"
"regexp"
"log"
"strconv"
"github.com/felixangell/strife"
"log"
"regexp"
"strconv"
)
type TomlConfig struct {
@ -39,7 +39,7 @@ type SyntaxCriteria struct {
Pattern string `toml:"pattern"`
CompiledPattern *regexp.Regexp
MatchList map[string]bool
MatchList map[string]bool
}
type Command struct {
@ -99,7 +99,7 @@ type EditorConfig struct {
Font_Face string
Font_Size int
Show_Line_Numbers bool
Loaded_Font *strife.Font
Loaded_Font *strife.Font
}
func NewDefaultConfig() *TomlConfig {

View File

@ -5,8 +5,8 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"regexp"
"runtime"
"strings"
"github.com/felixangell/strife"

View File

@ -1,10 +1,17 @@
package gui
import "os"
type BufferAction func(*Buffer) bool
var actions = map[string]BufferAction{
"save": Save,
"delete_line": DeleteLine,
"close_buffer": CloseBuffer,
"paste": Paste,
"paste": Paste,
"exit": func(*Buffer) bool {
// TODO do this properly lol
os.Exit(0)
return false
},
}

View File

@ -2,9 +2,9 @@ package gui
import (
"bytes"
"github.com/atotto/clipboard"
"io/ioutil"
"log"
"github.com/atotto/clipboard"
)
func Paste(b *Buffer) bool {

View File

@ -1,13 +1,13 @@
package lex
type Lexer struct {
pos int
pos int
input []rune
}
func New(input string) *Lexer {
return &Lexer {
pos: 0,
return &Lexer{
pos: 0,
input: []rune(input),
}
}
@ -19,7 +19,7 @@ func (l *Lexer) consume() rune {
}
func (l *Lexer) next(offs int) rune {
return l.input[l.pos + offs]
return l.input[l.pos+offs]
}
func (l *Lexer) peek() rune {
@ -48,7 +48,7 @@ func (l *Lexer) Tokenize() []*Token {
startPos := l.pos
for l.hasNext() {
// we run into a layout character
// we run into a layout character
if l.peek() <= ' ' {
break
}
@ -64,4 +64,4 @@ func (l *Lexer) Tokenize() []*Token {
result = append(result, tok)
}
return result
}
}

View File

@ -10,14 +10,14 @@ const (
type Token struct {
Lexeme string
Type TokenType
Start int
Type TokenType
Start int
}
func NewToken(lexeme string, kind TokenType, start int) *Token {
return &Token {lexeme, kind, start}
return &Token{lexeme, kind, start}
}
func (t *Token) String() string {
return fmt.Sprintf("lexeme: %s, type %s, at pos %d", t.Lexeme, t.Type, t.Start)
}
}