mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 23:05:40 -04: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)
|
return buffer.NewBufferFromFile(path, buffer.BTDefault)
|
||||||
}))
|
}))
|
||||||
ulua.L.SetField(pkg, "ByteOffset", luar.New(ulua.L, buffer.ByteOffset))
|
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
|
return pkg
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ var (
|
|||||||
flagVersion = flag.Bool("version", false, "Show the version number and information")
|
flagVersion = flag.Bool("version", false, "Show the version number and information")
|
||||||
flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory")
|
flagConfigDir = flag.String("config-dir", "", "Specify a custom location for the configuration directory")
|
||||||
flagOptions = flag.Bool("options", false, "Show all option help")
|
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
|
optionFlags map[string]*string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,6 +42,8 @@ func InitFlags() {
|
|||||||
fmt.Println(" \tThis can also be done by opening file:LINE:COL")
|
fmt.Println(" \tThis can also be done by opening file:LINE:COL")
|
||||||
fmt.Println("-options")
|
fmt.Println("-options")
|
||||||
fmt.Println(" \tShow all option help")
|
fmt.Println(" \tShow all option help")
|
||||||
|
fmt.Println("-debug")
|
||||||
|
fmt.Println(" \tEnable debug mode (enables logging to ./log.txt)")
|
||||||
fmt.Println("-version")
|
fmt.Println("-version")
|
||||||
fmt.Println(" \tShow the version number and information")
|
fmt.Println(" \tShow the version number and information")
|
||||||
|
|
||||||
@ -82,6 +85,10 @@ func InitFlags() {
|
|||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if util.Debug == "OFF" && *flagDebug {
|
||||||
|
util.Debug = "ON"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadInput determines which files should be loaded into buffers
|
// LoadInput determines which files should be loaded into buffers
|
||||||
@ -144,10 +151,10 @@ func main() {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
InitLog()
|
|
||||||
|
|
||||||
InitFlags()
|
InitFlags()
|
||||||
|
|
||||||
|
InitLog()
|
||||||
|
|
||||||
err = config.InitConfigDir(*flagConfigDir)
|
err = config.InitConfigDir(*flagConfigDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
screen.TermMessage(err)
|
screen.TermMessage(err)
|
||||||
|
@ -879,3 +879,8 @@ func (b *Buffer) Line(i int) string {
|
|||||||
func WriteLog(s string) {
|
func WriteLog(s string) {
|
||||||
LogBuf.EventHandler.Insert(LogBuf.End(), s)
|
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`
|
- `BTInfo`
|
||||||
- `NewBufferFromFile`
|
- `NewBufferFromFile`
|
||||||
- `ByteOffset`
|
- `ByteOffset`
|
||||||
|
- `Log`
|
||||||
|
- `LogBuf`
|
||||||
* `micro/util`
|
* `micro/util`
|
||||||
- `RuneAt`
|
- `RuneAt`
|
||||||
- `GetLeadingWhitespace`
|
- `GetLeadingWhitespace`
|
||||||
|
Loading…
Reference in New Issue
Block a user