Skip to content

Commit 437c0e0

Browse files
authored
Merge pull request #71 from ergochat/docupdate
update documentation, remove ForceUseInteractive
2 parents ae12781 + c1066ab commit 437c0e0

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

docs/MIGRATING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Here are some guidelines for APIs that have been removed or changed:
99
* The preferred name for `NewEx` is now `NewFromConfig` (`NewEx` is provided as a compatibility alias).
1010
* The preferred name for `(*Instance).Readline` is now `ReadLine` (`Readline` is provided as a compatibility alias).
1111
* `PrefixCompleterInterface` was removed in favor of exposing `PrefixCompleter` as a concrete struct type. In general, references to `PrefixCompleterInterface` can be changed to `*PrefixCompleter`.
12+
* `(Config).ForceUseInteractive` has been removed. Instead, set `(Config).FuncIsTerminal` to `func() bool { return true }`.

operation.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,10 @@ func (o *operation) GenPasswordConfig() *Config {
468468
Stdout: baseConfig.Stdout,
469469
Stderr: baseConfig.Stderr,
470470

471-
FuncIsTerminal: baseConfig.FuncIsTerminal,
472-
FuncMakeRaw: baseConfig.FuncMakeRaw,
473-
FuncExitRaw: baseConfig.FuncExitRaw,
474-
FuncOnWidthChanged: baseConfig.FuncOnWidthChanged,
475-
ForceUseInteractive: baseConfig.ForceUseInteractive,
471+
FuncIsTerminal: baseConfig.FuncIsTerminal,
472+
FuncMakeRaw: baseConfig.FuncMakeRaw,
473+
FuncExitRaw: baseConfig.FuncExitRaw,
474+
FuncOnWidthChanged: baseConfig.FuncOnWidthChanged,
476475
}
477476
}
478477

readline.go

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,56 @@ type Instance struct {
1919
}
2020

2121
type Config struct {
22-
// prompt supports ANSI escape sequence, so we can color some characters even in windows
22+
// Prompt is the input prompt (ANSI escape sequences are supported on all platforms)
2323
Prompt string
2424

25-
// readline will persist historys to file where HistoryFile specified
25+
// HistoryFile is the path to the file where persistent history will be stored
26+
// (empty string disables).
2627
HistoryFile string
27-
// specify the max length of historys, it's 500 by default, set it to -1 to disable history
28+
// HistoryLimit is the maximum number of history entries to store. If it is 0
29+
// or unset, the default value is 500; set to -1 to disable.
2830
HistoryLimit int
2931
DisableAutoSaveHistory bool
30-
// enable case-insensitive history searching
32+
// HistorySearchFold enables case-insensitive history searching.
3133
HistorySearchFold bool
3234

33-
// AutoCompleter will called once user press TAB
35+
// AutoComplete defines the tab-completion behavior. See the documentation for
36+
// the AutoCompleter interface for details.
3437
AutoComplete AutoCompleter
3538

3639
// Listener is an optional callback to intercept keypresses.
3740
Listener Listener
3841

42+
// Painter is an optional callback to rewrite the buffer for display.
3943
Painter Painter
4044

41-
// If VimMode is true, readline will in vim.insert mode by default
45+
// FuncFilterInputRune is an optional callback to translate keyboard inputs;
46+
// it takes in the input rune and returns (translation, ok). If ok is false,
47+
// the rune is skipped.
48+
FuncFilterInputRune func(rune) (rune, bool)
49+
50+
// VimMode enables Vim-style insert mode by default.
4251
VimMode bool
4352

4453
InterruptPrompt string
4554
EOFPrompt string
4655

47-
// Function that returns width, height of the terminal or -1,-1 if unknown
48-
FuncGetSize func() (width int, height int)
49-
50-
Stdin io.Reader
51-
Stdout io.Writer
52-
Stderr io.Writer
53-
5456
EnableMask bool
5557
MaskRune rune
5658

57-
// Whether to maintain an undo buffer (Ctrl+_ to undo if enabled)
59+
// Undo controls whether to maintain an undo buffer (if enabled,
60+
// Ctrl+_ will undo the previous action).
5861
Undo bool
5962

60-
// filter input runes (may be used to disable CtrlZ or for translating some keys to different actions)
61-
// -> output = new (translated) rune and true/false if continue with processing this one
62-
FuncFilterInputRune func(rune) (rune, bool)
63-
64-
// force use interactive even stdout is not a tty
65-
FuncIsTerminal func() bool
66-
FuncMakeRaw func() error
67-
FuncExitRaw func() error
68-
FuncOnWidthChanged func(func())
69-
ForceUseInteractive bool
63+
// These fields allow customizing terminal handling. Most clients should ignore them.
64+
Stdin io.Reader
65+
Stdout io.Writer
66+
Stderr io.Writer
67+
FuncIsTerminal func() bool
68+
FuncMakeRaw func() error
69+
FuncExitRaw func() error
70+
FuncGetSize func() (width int, height int)
71+
FuncOnWidthChanged func(func())
7072

7173
// private fields
7274
inited bool
@@ -123,7 +125,7 @@ func (c *Config) init() error {
123125
c.Painter = defaultPainter
124126
}
125127

126-
c.isInteractive = c.ForceUseInteractive || c.FuncIsTerminal()
128+
c.isInteractive = c.FuncIsTerminal()
127129

128130
return nil
129131
}

0 commit comments

Comments
 (0)