summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolkit/gocui/fakefile.go45
-rw-r--r--toolkit/gocui/showMsg.go3
2 files changed, 47 insertions, 1 deletions
diff --git a/toolkit/gocui/fakefile.go b/toolkit/gocui/fakefile.go
new file mode 100644
index 0000000..2cdfca1
--- /dev/null
+++ b/toolkit/gocui/fakefile.go
@@ -0,0 +1,45 @@
+package main
+
+import (
+ "bytes"
+ "io"
+)
+
+type FakeFile struct {
+ buffer bytes.Buffer
+ offset int64
+}
+
+func (f *FakeFile) Read(p []byte) (n int, err error) {
+ n, err = f.buffer.ReadAt(p, f.offset)
+ f.offset += int64(n)
+ return n, err
+}
+
+func (f *FakeFile) Write(p []byte) (n int, err error) {
+ n, err = f.buffer.WriteAt(p, f.offset)
+ f.offset += int64(n)
+ return n, err
+}
+
+func (f *FakeFile) Seek(offset int64, whence int) (int64, error) {
+ newOffset := f.offset
+
+ switch whence {
+ case io.SeekStart:
+ newOffset = offset
+ case io.SeekCurrent:
+ newOffset += offset
+ case io.SeekEnd:
+ newOffset = int64(f.buffer.Len()) + offset
+ default:
+ return 0, io.ErrInvalidWhence
+ }
+
+ if newOffset < 0 {
+ return 0, io.ErrInvalidWhence
+ }
+
+ f.offset = newOffset
+ return f.offset, nil
+}
diff --git a/toolkit/gocui/showMsg.go b/toolkit/gocui/showMsg.go
index 2a0a873..f3cd0e7 100644
--- a/toolkit/gocui/showMsg.go
+++ b/toolkit/gocui/showMsg.go
@@ -44,6 +44,7 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
l += "foo\n" + "bar\n"
fmt.Fprintln(v, l)
}
- g.SetViewOnTop("msg")
+ // g.SetViewOnTop("msg")
+ g.SetViewOnBottom("msg")
return nil
}