package buffer
import (
+ "bufio"
"bytes"
"crypto/md5"
"errors"
"io"
"io/ioutil"
+ "log"
"os"
"path/filepath"
"strconv"
luar "layeh.com/gopher-luar"
+ dmp "github.com/sergi/go-diff/diffmatchpatch"
"github.com/zyedidia/micro/internal/config"
ulua "github.com/zyedidia/micro/internal/lua"
"github.com/zyedidia/micro/internal/screen"
"golang.org/x/text/encoding/htmlindex"
"golang.org/x/text/encoding/unicode"
"golang.org/x/text/transform"
- dmp "github.com/sergi/go-diff/diffmatchpatch"
)
const backupTime = 8000
b.Settings["encoding"] = "utf-8"
}
- reader := transform.NewReader(r, enc.NewDecoder())
+ reader := bufio.NewReader(transform.NewReader(r, enc.NewDecoder()))
found := false
if len(path) > 0 {
b.UpdateRules()
config.InitLocalSettings(b.Settings, b.Path)
- if _, err := os.Stat(config.ConfigDir + "/buffers/"); os.IsNotExist(err) {
- os.Mkdir(config.ConfigDir+"/buffers/", os.ModePerm)
+ if _, err := os.Stat(filepath.Join(config.ConfigDir, "buffers")); os.IsNotExist(err) {
+ os.Mkdir(filepath.Join(config.ConfigDir, "buffers"), os.ModePerm)
}
if startcursor.X != -1 && startcursor.Y != -1 {
return err
}
- reader := transform.NewReader(file, enc.NewDecoder())
+ reader := bufio.NewReader(transform.NewReader(file, enc.NewDecoder()))
data, err := ioutil.ReadAll(reader)
txt := string(data)
if syntaxFile == "" {
// search for the syntax file in the user's custom syntax files
for _, f := range config.ListRealRuntimeFiles(config.RTSyntax) {
+ log.Println("real runtime file", f.Name())
data, err := f.Data()
if err != nil {
screen.TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
continue
}
- if (ft == "unknown" || ft == "" && highlight.MatchFiletype(header.FtDetect, b.Path, b.lines[0].data)) || header.FileType == ft {
+ if ((ft == "unknown" || ft == "") && highlight.MatchFiletype(header.FtDetect, b.Path, b.lines[0].data)) || header.FileType == ft {
syndef, err := highlight.ParseDef(file, header)
if err != nil {
screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
go func() {
b.Highlighter.HighlightStates(b)
b.Highlighter.HighlightMatches(b, 0, b.End().Y)
- screen.DrawChan <- true
+ screen.Redraw()
}()
}
}
l = bytes.TrimLeft(l, " \t")
b.lines[i].data = append(ws, l...)
+ b.Modifications = append(b.Modifications, Loc{i, i})
dirty = true
}
b.diffBaseLineCount = strings.Count(string(diffBase), "\n")
}
b.UpdateDiff(func(synchronous bool) {
- screen.DrawChan <- true
+ screen.Redraw()
})
}