mirror of
https://github.com/walles/moar.git
synced 2024-11-22 21:50:43 +03:00
Extract editing into a function
This commit is contained in:
parent
df79efefa7
commit
0ac8dede4a
@ -122,6 +122,7 @@ Miscellaneous
|
||||
* Press 'q' or 'ESC' to quit
|
||||
* Press 'w' to toggle wrapping of long lines
|
||||
* Press '=' to toggle showing the status bar at the bottom
|
||||
* Press 'v' to edit the file in your favorite editor
|
||||
|
||||
Moving around
|
||||
-------------
|
||||
|
@ -1,8 +1,6 @@
|
||||
package m
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/walles/moar/twin"
|
||||
)
|
||||
@ -71,6 +69,24 @@ func (m PagerModeViewing) onKey(keyCode twin.KeyCode) {
|
||||
}
|
||||
}
|
||||
|
||||
func handleEditingRequest() {
|
||||
// FIXME: Get an editor setting from either VISUAL or EDITOR
|
||||
|
||||
// FIXME: Tyre kicking check that we can launch the editor
|
||||
|
||||
// FIXME: If the buffer is from stdin, store it in a temp file. Consider
|
||||
// naming it based on the current language setting.
|
||||
|
||||
// FIXME: Set an AfterExit function that launches the editor
|
||||
|
||||
p.AfterExit = func() error {
|
||||
FIXME: Do editor launching things here
|
||||
_, err := fmt.Println("JOHAN: Imagine launching an editor here")
|
||||
return err
|
||||
}
|
||||
p.Quit()
|
||||
}
|
||||
|
||||
func (m PagerModeViewing) onRune(char rune) {
|
||||
p := m.pager
|
||||
|
||||
@ -79,12 +95,7 @@ func (m PagerModeViewing) onRune(char rune) {
|
||||
p.Quit()
|
||||
|
||||
case 'v':
|
||||
p.AfterExit = func() error {
|
||||
FIXME: Do editor launching things here
|
||||
_, err := fmt.Println("JOHAN: Imagine launching an editor here")
|
||||
return err
|
||||
}
|
||||
p.Quit()
|
||||
handleEditingRequest()
|
||||
|
||||
case '?':
|
||||
if !p.isShowingHelp {
|
||||
|
Loading…
Reference in New Issue
Block a user