github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/cmds/elvish/edit/raw_insert.go (about)

     1  package edit
     2  
     3  import (
     4  	"github.com/u-root/u-root/cmds/elvish/edit/ui"
     5  	"github.com/u-root/u-root/cmds/elvish/eval"
     6  )
     7  
     8  // Raw insert mode is a special mode, in that it does not use the normal key
     9  // binding. Rather, insertRaw is called directly from the main loop in
    10  // Editor.ReadLine.
    11  
    12  type rawInsert struct {
    13  }
    14  
    15  func (ed *editor) startInsertRaw() {
    16  	ed.reader.SetRaw(true)
    17  	ed.mode = rawInsert{}
    18  }
    19  
    20  func insertRaw(ed *editor, r rune) {
    21  	ed.InsertAtDot(string(r))
    22  	ed.reader.SetRaw(false)
    23  	ed.SetModeInsert()
    24  }
    25  
    26  func (rawInsert) Teardown() {}
    27  
    28  func (rawInsert) Binding(ui.Key) eval.Callable {
    29  	// The raw insert mode does not handle keys.
    30  	return nil
    31  }
    32  
    33  func (ri rawInsert) ModeLine() ui.Renderer {
    34  	return ui.NewModeLineRenderer(" RAW ", "")
    35  }