]> git.lizzy.rs Git - micro.git/blobdiff - internal/util/util.go
Update documentation to include Material colorscheme (#1279)
[micro.git] / internal / util / util.go
index 92af3bce969b5228af2e7a60369bfcb03637dcec..485d4f55276d691fef24383320c4c7c77a7d5c33 100644 (file)
@@ -7,6 +7,7 @@ import (
        "os/user"
        "path/filepath"
        "regexp"
+       "runtime"
        "strconv"
        "strings"
        "time"
@@ -30,6 +31,9 @@ var (
        CompileDate = "Unknown"
        // Debug logging
        Debug = "ON"
+       // FakeCursor is used to disable the terminal cursor and have micro
+       // draw its own (enabled for windows consoles where the cursor is slow)
+       FakeCursor = false
 )
 
 func init() {
@@ -38,6 +42,10 @@ func init() {
        if err != nil {
                fmt.Println("Invalid version: ", Version, err)
        }
+
+       if runtime.GOOS == "windows" {
+               FakeCursor = true
+       }
 }
 
 // SliceEnd returns a byte slice where the index is a rune index
@@ -267,7 +275,6 @@ func MakeRelative(path, base string) (string, error) {
        return path, nil
 }
 
-// TODO: consider changing because of snap segfault
 // ReplaceHome takes a path as input and replaces ~ at the start of the path with the user's
 // home directory. Does nothing if the path does not start with '~'.
 func ReplaceHome(path string) (string, error) {
@@ -410,3 +417,8 @@ func IsNonAlphaNumeric(c rune) bool {
 func ParseSpecial(s string) string {
        return strings.Replace(s, "\\t", "\t", -1)
 }
+
+// String converts a byte array to a string (for lua plugins)
+func String(s []byte) string {
+       return string(s)
+}