...

Source file src/github.com/c-bata/go-prompt/key_bind_func.go

Documentation: github.com/c-bata/go-prompt

     1  package prompt
     2  
     3  // GoLineEnd Go to the End of the line
     4  func GoLineEnd(buf *Buffer) {
     5  	x := []rune(buf.Document().TextAfterCursor())
     6  	buf.CursorRight(len(x))
     7  }
     8  
     9  // GoLineBeginning Go to the beginning of the line
    10  func GoLineBeginning(buf *Buffer) {
    11  	x := []rune(buf.Document().TextBeforeCursor())
    12  	buf.CursorLeft(len(x))
    13  }
    14  
    15  // DeleteChar Delete character under the cursor
    16  func DeleteChar(buf *Buffer) {
    17  	buf.Delete(1)
    18  }
    19  
    20  // DeleteWord Delete word before the cursor
    21  func DeleteWord(buf *Buffer) {
    22  	buf.DeleteBeforeCursor(len([]rune(buf.Document().TextBeforeCursor())) - buf.Document().FindStartOfPreviousWordWithSpace())
    23  }
    24  
    25  // DeleteBeforeChar Go to Backspace
    26  func DeleteBeforeChar(buf *Buffer) {
    27  	buf.DeleteBeforeCursor(1)
    28  }
    29  
    30  // GoRightChar Forward one character
    31  func GoRightChar(buf *Buffer) {
    32  	buf.CursorRight(1)
    33  }
    34  
    35  // GoLeftChar Backward one character
    36  func GoLeftChar(buf *Buffer) {
    37  	buf.CursorLeft(1)
    38  }
    39  
    40  // GoRightWord Forward one word
    41  func GoRightWord(buf *Buffer) {
    42  	buf.CursorRight(buf.Document().FindEndOfCurrentWordWithSpace())
    43  }
    44  
    45  // GoLeftWord Backward one word
    46  func GoLeftWord(buf *Buffer) {
    47  	buf.CursorLeft(len([]rune(buf.Document().TextBeforeCursor())) - buf.Document().FindStartOfPreviousWordWithSpace())
    48  }
    49  

View as plain text