action.InitTabs(b)
action.InitGlobals()
- for _, s := range config.LocalSettings {
- if _, ok := config.GlobalSettings[s]; ok {
- delete(config.GlobalSettings, s)
- }
- }
-
// Here is the event loop which runs in a separate thread
go func() {
events = make(chan tcell.Event)
package action
import (
- "log"
"strings"
"time"
return false
}
rel := action(h)
- log.Println("calling on", estr)
if h.PluginCB("on"+estr) && rel {
h.Relocate()
}
import (
"errors"
"fmt"
- "log"
"os"
"path/filepath"
"regexp"
screen.TermMessage(err)
}
- log.Println("RELOAD CONFIG", len(buffer.OpenBuffers))
for _, b := range buffer.OpenBuffers {
- log.Println("UPDATE RULES")
b.UpdateRules()
}
}
option := args[0]
defaultGlobals := config.DefaultGlobalSettings()
- defaultLocals := config.DefaultLocalSettings()
+ defaultLocals := config.DefaultCommonSettings()
if _, ok := defaultGlobals[option]; ok {
SetGlobalOptionNative(option, defaultGlobals[option])
input, argstart := buffer.GetArg(b)
var suggestions []string
- localSettings := config.DefaultLocalSettings()
for option := range config.GlobalSettings {
if strings.HasPrefix(option, input) {
suggestions = append(suggestions, option)
}
}
- for option := range localSettings {
- if strings.HasPrefix(option, input) && !contains(suggestions, option) {
- suggestions = append(suggestions, option)
- }
- }
+ // for option := range localSettings {
+ // if strings.HasPrefix(option, input) && !contains(suggestions, option) {
+ // suggestions = append(suggestions, option)
+ // }
+ // }
sort.Strings(suggestions)
completions := make([]string, len(suggestions))
completeValue := false
args := bytes.Split(l, []byte{' '})
if len(args) >= 2 {
- localSettings := config.DefaultLocalSettings()
+ // localSettings := config.DefaultLocalSettings()
for option := range config.GlobalSettings {
if option == string(args[len(args)-2]) {
completeValue = true
break
}
}
- for option := range localSettings {
- if option == string(args[len(args)-2]) {
- completeValue = true
- break
- }
- }
+ // for option := range localSettings {
+ // if option == string(args[len(args)-2]) {
+ // completeValue = true
+ // break
+ // }
+ // }
}
if !completeValue {
return OptionComplete(b)
inputOpt = strings.TrimSpace(inputOpt)
var suggestions []string
- localSettings := config.DefaultLocalSettings()
+ // localSettings := config.DefaultLocalSettings()
var optionVal interface{}
for k, option := range config.GlobalSettings {
if k == inputOpt {
optionVal = option
}
}
- for k, option := range localSettings {
- if k == inputOpt {
- optionVal = option
- }
- }
+ // for k, option := range localSettings {
+ // if k == inputOpt {
+ // optionVal = option
+ // }
+ // }
switch optionVal.(type) {
case bool:
"errors"
"io"
"io/ioutil"
- "log"
"os"
"path/filepath"
"strconv"
b := new(Buffer)
- b.Settings = config.DefaultLocalSettings()
+ b.Settings = config.DefaultCommonSettings()
for k, v := range config.GlobalSettings {
if _, ok := b.Settings[k]; ok {
b.Settings[k] = v
func (b *Buffer) Insert(start Loc, text string) {
if !b.Type.Readonly {
- log.Println("INSERT", start, text)
b.EventHandler.cursors = b.cursors
b.EventHandler.active = b.curCursor
b.EventHandler.Insert(start, text)
import (
"errors"
- "log"
lua "github.com/yuin/gopher-lua"
ulua "github.com/zyedidia/micro/internal/lua"
func (p *Plugin) Call(fn string, args ...lua.LValue) (lua.LValue, error) {
plug := ulua.L.GetGlobal(p.Name)
- log.Println(p.Name, fn, plug)
luafn := ulua.L.GetField(plug, fn)
if luafn == lua.LNil {
return nil, ErrNoSuchFunction
import (
"io/ioutil"
- "log"
"os"
"path"
"path/filepath"
// Search ConfigDir for plugin-scripts
plugdir := filepath.Join(ConfigDir, "plugins")
files, _ := ioutil.ReadDir(plugdir)
- log.Println("reading", plugdir)
for _, d := range files {
if d.IsDir() {
srcs, _ := ioutil.ReadDir(filepath.Join(plugdir, d.Name()))
return nil
}
-func RegisterLocalOption(name string, defaultvalue interface{}) {
- defaultLocalSettings[name] = defaultvalue
-}
-
func RegisterGlobalOption(name string, defaultvalue interface{}) error {
if v, ok := GlobalSettings[name]; !ok {
defaultGlobalSettings[name] = defaultvalue
"eofnewline": false,
"fastdirty": true,
"fileformat": "unix",
+ "filetype": "unknown",
"ignorecase": false,
"indentchar": " ",
"keepautoindent": false,
"matchbrace": false,
"matchbraceleft": false,
+ "readonly": false,
"rmtrailingws": false,
"ruler": true,
"savecursor": false,
return offset
}
+// DefaultCommonSettings returns the default global settings for micro
+// Note that colorscheme is a global only option
+func DefaultCommonSettings() map[string]interface{} {
+ commonsettings := make(map[string]interface{})
+ for k, v := range defaultCommonSettings {
+ commonsettings[k] = v
+ }
+ return commonsettings
+}
+
var defaultGlobalSettings = map[string]interface{}{
"colorscheme": "default",
"infobar": true,
return globalsettings
}
-// LocalSettings is a list of the local only settings
-var LocalSettings = []string{"filetype", "readonly"}
-
-var defaultLocalSettings = map[string]interface{}{
- "filetype": "unknown",
- "readonly": false,
-}
-
-// DefaultLocalSettings returns the default local settings
-// Note that filetype is a local only option
-func DefaultLocalSettings() map[string]interface{} {
- localsettings := make(map[string]interface{})
- for k, v := range defaultCommonSettings {
- localsettings[k] = v
- }
- for k, v := range defaultLocalSettings {
- localsettings[k] = v
- }
- return localsettings
-}
-
// DefaultAllSettings returns a map of all settings and their
-// default values (both local and global settings)
+// default values (both common and global settings)
func DefaultAllSettings() map[string]interface{} {
allsettings := make(map[string]interface{})
for k, v := range defaultCommonSettings {
for k, v := range defaultGlobalSettings {
allsettings[k] = v
}
- for k, v := range defaultLocalSettings {
- allsettings[k] = v
- }
return allsettings
}
package display
import (
- "log"
"strconv"
"unicode/utf8"
ret := false
activeC := w.Buf.GetActiveCursor()
cy := activeC.Y
- log.Println("RELOCATE", w.StartLine, cy, height)
scrollmargin := int(b.Settings["scrollmargin"].(float64))
if cy < w.StartLine+scrollmargin && cy > scrollmargin-1 {
- log.Println("a")
w.StartLine = cy - scrollmargin
ret = true
} else if cy < w.StartLine {
- log.Println("b")
w.StartLine = cy
ret = true
}
if cy > w.StartLine+height-1-scrollmargin && cy < b.LinesNum()-scrollmargin {
- log.Println("c")
w.StartLine = cy - height + 1 + scrollmargin
ret = true
} else if cy >= b.LinesNum()-scrollmargin && cy >= height {
- log.Println("d")
w.StartLine = b.LinesNum() - height
ret = true
}
- log.Println("RELOCATE DONE", w.StartLine)
// horizontal relocation (scrolling)
if !b.Settings["softwrap"].(bool) {
// displayBuffer draws the buffer being shown in this window on the screen.Screen
func (w *BufWindow) displayBuffer() {
- log.Println("STARTLINE", w.StartLine)
b := w.Buf
hasMessage := len(b.Messages) > 0
import (
"errors"
"fmt"
- "log"
"os"
"os/user"
"path/filepath"
// IsWordChar returns whether or not the string is a 'word character'
// Word characters are defined as numbers, letters, or '_'
func IsWordChar(r rune) bool {
- log.Println("IsWordChar")
return unicode.IsLetter(r) || unicode.IsNumber(r) || r == '_'
}