Skip to content

Commit

Permalink
Update to use new mkinfo from tcell
Browse files Browse the repository at this point in the history
This update incorporates the new terminfo updates in tcell into micro
essentially merging zyedidia/mkinfo into micro. The zyedidia/mkinfo
program should no longer be necessary and micro should automatically
generate a tcell database on its own if it cannot find a terminal
entry. The tcell database will be located in `configDir/.tcelldb`.

Ref #20
Ref #922
  • Loading branch information
zyedidia committed Jan 30, 2018
1 parent f481168 commit 96c7b1d
Show file tree
Hide file tree
Showing 5 changed files with 1,564 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmd/micro/micro.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/mitchellh/go-homedir"
"github.com/yuin/gopher-lua"
"github.com/zyedidia/clipboard"
"github.com/zyedidia/micro/cmd/micro/terminfo"
"github.com/zyedidia/tcell"
"github.com/zyedidia/tcell/encoding"
"layeh.com/gopher-luar"
Expand Down Expand Up @@ -183,6 +184,9 @@ func InitScreen() {
// Should we enable true color?
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"

tcelldb := os.Getenv("TCELLDB")
os.Setenv("TCELLDB", configDir+"/.tcelldb")

// In order to enable true color, we have to set the TERM to `xterm-truecolor` when
// initializing tcell, but after that, we can set the TERM back to whatever it was
oldTerm := os.Getenv("TERM")
Expand All @@ -194,12 +198,15 @@ func InitScreen() {
var err error
screen, err = tcell.NewScreen()
if err != nil {
fmt.Println(err)
if err == tcell.ErrTermNotFound {
fmt.Println("Micro does not recognize your terminal:", oldTerm)
fmt.Println("Please go to https://github.com/zyedidia/mkinfo to read about how to fix this problem (it should be easy to fix).")
terminfo.WriteDB(configDir + "/.tcelldb")
screen, err = tcell.NewScreen()
if err != nil {
fmt.Println(err)
fmt.Println("Fatal: Micro could not initialize a screen.")
os.Exit(1)
}
}
os.Exit(1)
}
if err = screen.Init(); err != nil {
fmt.Println(err)
Expand All @@ -215,6 +222,8 @@ func InitScreen() {
screen.EnableMouse()
}

os.Setenv("TCELLDB", tcelldb)

// screen.SetStyle(defStyle)
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/micro/terminfo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Terminfo parser

This terminfo parser was written by the authors of [tcell](github.com/gdamore/tcell). We are using it here
to compile the terminal database if the terminal entry is not found in set of precompiled terminals.

The source for `mkinfo.go` is adapted from tcell's `mkinfo` tool to be more of a library.
Loading

0 comments on commit 96c7b1d

Please sign in to comment.