go-prompt/_tools
2017-08-12 23:43:35 +09:00
..
erasing.go Rename package 2017-08-08 00:19:51 +09:00
README.md Update README 2017-08-12 23:43:35 +09:00
vt100_debug.go Rename package 2017-08-08 00:19:51 +09:00
window_size.go Run goimports 2017-07-18 05:32:14 +09:00

Internals of go-prompt

This is a short description of go-prompt implementation. go-prompt consists of three parts.

  1. Input parser
  2. Emulate user input with Buffer object.
  3. Render buffer object.

Input Parser

input-parser animation

Input Parser only supports only vt100 compatible console now.

  • Set raw mode.
  • Read standard input.
  • Parse byte array

Emulate user input

go-prompt contains Buffer class. It represents input state by handling user input key.

Buffer object has text and cursor position.

TODO prepare the sample of buffer

package main

import "github.com/c-bata/go-prompt"

func main() {
  b := prompt.NewBuffer()
  ... wip
}

Renderer

Renderer object renders a buffer object.

TODO prepare the sample of brender

package main

the output is below:

TODO prepare a screen shot