aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--editor/buffer.go8
-rw-r--r--todo1
-rw-r--r--ui/tcell/tcell.go14
-rw-r--r--ui/tcell/window.go2
5 files changed, 25 insertions, 2 deletions
diff --git a/README.md b/README.md
index 1aff1d2..c1b85d1 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,8 @@ Everything is text and everything is editable. There are two ways to interact wi
`Del` closes current window. If it is the last window, the program will exit.
+`Get` reloads the buffer from disk, wiping any changes you have made since the file was last read.
+
`Exit` closes all windows and exits the program.
Run command on `date` executes `date` as a shell command and presents its output in the message window named `+poe`. Or `pwd`, or `ls -l`, or `curl google.se`, or... you get the idea.
diff --git a/editor/buffer.go b/editor/buffer.go
index 54ac23e..503cf02 100644
--- a/editor/buffer.go
+++ b/editor/buffer.go
@@ -246,6 +246,14 @@ func (b *Buffer) Delete() (int, error) {
return n, nil
}
+// Destroy will mark the buffer as completely empty and reset to 0.
+func (b *Buffer) Destroy() {
+ b.buf.Destroy()
+ b.SetDot(0, 0)
+ b.dirty = false
+ b.file.read = false
+}
+
// Len returns the number of bytes in buffer.
func (b *Buffer) Len() int {
b.initBuffer()
diff --git a/todo b/todo
index 26afc62..540a7a5 100644
--- a/todo
+++ b/todo
@@ -5,7 +5,6 @@ file
backup files on disk
window
hide / collapse
- command Get (update buffer content)
open files with line number, eg poe.go:25
text
int64 as default in case of large files
diff --git a/ui/tcell/tcell.go b/ui/tcell/tcell.go
index 20b59d5..ad27bd5 100644
--- a/ui/tcell/tcell.go
+++ b/ui/tcell/tcell.go
@@ -138,6 +138,7 @@ func initCommands() {
"New": CmdNew,
"Newcol": CmdNewcol,
"Del": CmdDel,
+ "Get": CmdGet,
"Exit": CmdExit,
}
}
@@ -266,6 +267,19 @@ func CmdNewcol() {
CmdNew()
}
+func CmdGet() {
+ screen.Clear()
+ wins := AllWindows()
+ for _, win := range wins {
+ if win.tagline.focused {
+ q0, q1 := win.body.text.Dot()
+ win.body.text.Destroy()
+ win.body.text.ReadFile()
+ win.body.text.SetDot(q0, q1)
+ }
+ }
+}
+
func CmdExit() {
exit := true
wins := AllWindows()
diff --git a/ui/tcell/window.go b/ui/tcell/window.go
index ba4220c..86f9ce4 100644
--- a/ui/tcell/window.go
+++ b/ui/tcell/window.go
@@ -41,7 +41,7 @@ func NewWindow(id int64) *Window {
},
}
- fmt.Fprintf(win.tagline, "%s Del ",
+ fmt.Fprintf(win.tagline, "%s Del Get ",
win.TagName(),
)