1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'master' into master

This commit is contained in:
Chris Cummer
2018-06-08 11:59:54 -07:00
committed by GitHub
29 changed files with 56 additions and 128 deletions

View File

@@ -3,4 +3,5 @@ package wtf
type Enabler interface {
Disabled() bool
Enabled() bool
Disable()
}

26
wtf/log.go Normal file
View File

@@ -0,0 +1,26 @@
package wtf
import (
"log"
"os"
"path/filepath"
)
//Log basic message logging, defaults to ~/.wtf/log.txt
func Log(message string) {
dir, err := Home()
if err != nil {
return
}
logfile := filepath.Join(dir, ".wtf", "log.txt")
f, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer f.Close()
log.SetOutput(f)
log.Println(message)
}

View File

@@ -61,6 +61,10 @@ func (widget *TextWidget) Enabled() bool {
return widget.enabled
}
func (widget *TextWidget) Disable() {
widget.enabled = false
}
func (widget *TextWidget) Focusable() bool {
return widget.enabled && widget.focusable
}