Skip to content

Commit

Permalink
actions: add Tagline command
Browse files Browse the repository at this point in the history
  • Loading branch information
josephholsten committed Jul 1, 2016
1 parent 86a4045 commit 450a6c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Binary file modified COMMANDS.md
Binary file not shown.
5 changes: 5 additions & 0 deletions actions/defaults/defaultactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func init() {
actions.RegisterAction("SaveOrQuit", SaveOrExit)
actions.RegisterAction("Paste", Paste)
actions.RegisterAction("ResetTagline", ResetTagline)
actions.RegisterAction("Tagline", Tagline)

// Change the renderer by name
actions.RegisterAction("Renderer", SwitchRenderer)
Expand Down Expand Up @@ -105,6 +106,10 @@ func ResetTagline(args string, buff *demodel.CharBuffer, v demodel.Viewport) {
buff.ResetTagline()
}

func Tagline(args string, buff *demodel.CharBuffer, v demodel.Viewport) {
buff.SetTagline(args)
}

func SwitchRenderer(args string, buff *demodel.CharBuffer, v demodel.Viewport) {
r := renderer.GetNamedRenderer(args)
if r == nil || v == nil {
Expand Down
8 changes: 8 additions & 0 deletions demodel/charbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ func (c *CharBuffer) ResetTagline() error {
return nil
}

func (c *CharBuffer) SetTagline(val string) error {
c.Tagline = &CharBuffer{Buffer: []byte(c.Filename)}
c.AppendTag(" | " + val)
c.Tagline.Dot.Start = uint(len(c.Tagline.Buffer))
c.Tagline.Dot.End = c.Tagline.Dot.Start
return nil
}

func getSnarfSaveDir() string {
u, err := user.Current()
if err != nil {
Expand Down

0 comments on commit 450a6c0

Please sign in to comment.