Skip to content

v0.12.0

Compare
Choose a tag to compare
@hymkor hymkor released this 04 Sep 06:12
· 7 commits to master since this release
  • Fix: Dirty flag was not set on inserting an empty line after an empty line
  • Implement (*Editor) SubmitOnEnterWhen that can specify the condition to terminate input when Enter-key is pressed.

In the following example, if the last line ends with a semicolon, the Enter key is assumed to be the input end.
(The first argument is all lines, the second argument is the cursor line position)


  • 空行の後に空行を挿入した時に、変更フラグが立たなかった不具合を修正
  • (*Editor) SubmitOnEnterWhen を実装: Enter だけを入力した時にそれを入力終結と判断する条件を指定できます。

次の例では、最後の行の行末がセミコロンで終わっている場合、Enter キーで入力エンドとみなします。
(第一引数は全行、第二引数はカーソルの行位置です)

var ed multiline.Editor

ed.SubmitOnEnterWhen(func(lines []string, _ int) bool {
		return strings.HasSuffix(strings.TrimSpace(lines[len(lines)-1]), ";")
})