mirror of
https://github.com/zyedidia/micro.git
synced 2024-10-27 12:37:38 +03:00
Make debug mode flag, plugins can access logbuf
This commit is contained in:
parent
fa4103f7aa
commit
b3e40a2644
@ -117,6 +117,8 @@ func luaImportMicroBuffer() *lua.LTable {
|
||||
return buffer.NewBufferFromFile(path, buffer.BTDefault)
|
||||
}))
|
||||
ulua.L.SetField(pkg, "ByteOffset", luar.New(ulua.L, buffer.ByteOffset))
|
||||
ulua.L.SetField(pkg, "Log", luar.New(ulua.L, buffer.WriteLog))
|
||||
ulua.L.SetField(pkg, "LogBuf", luar.New(ulua.L, buffer.GetLogBuf))
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ var (
|
||||
flagVersion = flag.Bool("version", false, "Show the version number and information")
|
||||
flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory")
|
||||
flagOptions = flag.Bool("options", false, "Show all option help")
|
||||
flagDebug = flag.Bool("debug", false, "Enable debug mode (prints debug info to ./log.txt)")
|
||||
optionFlags map[string]*string
|
||||
)
|
||||
|
||||
@ -41,6 +42,8 @@ func InitFlags() {
|
||||
fmt.Println(" \tThis can also be done by opening file:LINE:COL")
|
||||
fmt.Println("-options")
|
||||
fmt.Println(" \tShow all option help")
|
||||
fmt.Println("-debug")
|
||||
fmt.Println(" \tEnable debug mode (enables logging to ./log.txt)")
|
||||
fmt.Println("-version")
|
||||
fmt.Println(" \tShow the version number and information")
|
||||
|
||||
@ -82,6 +85,10 @@ func InitFlags() {
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if util.Debug == "OFF" && *flagDebug {
|
||||
util.Debug = "ON"
|
||||
}
|
||||
}
|
||||
|
||||
// LoadInput determines which files should be loaded into buffers
|
||||
@ -144,10 +151,10 @@ func main() {
|
||||
|
||||
var err error
|
||||
|
||||
InitLog()
|
||||
|
||||
InitFlags()
|
||||
|
||||
InitLog()
|
||||
|
||||
err = config.InitConfigDir(*flagConfigDir)
|
||||
if err != nil {
|
||||
screen.TermMessage(err)
|
||||
|
@ -879,3 +879,8 @@ func (b *Buffer) Line(i int) string {
|
||||
func WriteLog(s string) {
|
||||
LogBuf.EventHandler.Insert(LogBuf.End(), s)
|
||||
}
|
||||
|
||||
// GetLogBuf returns the log buffer
|
||||
func GetLogBuf() *Buffer {
|
||||
return LogBuf
|
||||
}
|
||||
|
@ -178,6 +178,8 @@ The packages and functions are listed below (in Go type signatures):
|
||||
- `BTInfo`
|
||||
- `NewBufferFromFile`
|
||||
- `ByteOffset`
|
||||
- `Log`
|
||||
- `LogBuf`
|
||||
* `micro/util`
|
||||
- `RuneAt`
|
||||
- `GetLeadingWhitespace`
|
||||
|
Loading…
Reference in New Issue
Block a user