@@ -103,36 +103,36 @@ using SuggestionCallbackType =
103
103
using CompleteCallbackType = llvm::unique_function<void (CompletionRequest &)>;
104
104
105
105
// / Status used to decide when and how to start editing another line in
106
- // / multi-line sessions
106
+ // / multi-line sessions.
107
107
enum class EditorStatus {
108
108
109
- // / The default state proceeds to edit the current line
109
+ // / The default state proceeds to edit the current line.
110
110
Editing,
111
111
112
- // / Editing complete, returns the complete set of edited lines
112
+ // / Editing complete, returns the complete set of edited lines.
113
113
Complete,
114
114
115
- // / End of input reported
115
+ // / End of input reported.
116
116
EndOfInput,
117
117
118
- // / Editing interrupted
118
+ // / Editing interrupted.
119
119
Interrupted
120
120
};
121
121
122
- // / Established locations that can be easily moved among with MoveCursor
122
+ // / Established locations that can be easily moved among with MoveCursor.
123
123
enum class CursorLocation {
124
- // / The start of the first line in a multi-line edit session
124
+ // / The start of the first line in a multi-line edit session.
125
125
BlockStart,
126
126
127
- // / The start of the current line in a multi-line edit session
127
+ // / The start of the current line in a multi-line edit session.
128
128
EditingPrompt,
129
129
130
130
// / The location of the cursor on the current line in a multi-line edit
131
- // / session
131
+ // / session.
132
132
EditingCursor,
133
133
134
134
// / The location immediately after the last character in a multi-line edit
135
- // / session
135
+ // / session.
136
136
BlockEnd
137
137
};
138
138
@@ -149,8 +149,7 @@ enum class HistoryOperation {
149
149
using namespace line_editor ;
150
150
151
151
// / Instances of Editline provide an abstraction over libedit's EditLine
152
- // / facility. Both
153
- // / single- and multi-line editing are supported.
152
+ // / facility. Both single- and multi-line editing are supported.
154
153
class Editline {
155
154
public:
156
155
Editline (const char *editor_name, FILE *input_file, FILE *output_file,
@@ -168,23 +167,22 @@ class Editline {
168
167
void SetPrompt (const char *prompt);
169
168
170
169
// / Sets an alternate string to be used as a prompt for the second line and
171
- // / beyond in multi-line
172
- // / editing scenarios.
170
+ // / beyond in multi-line editing scenarios.
173
171
void SetContinuationPrompt (const char *continuation_prompt);
174
172
175
- // / Call when the terminal size changes
173
+ // / Call when the terminal size changes.
176
174
void TerminalSizeChanged ();
177
175
178
- // / Returns the prompt established by SetPrompt()
176
+ // / Returns the prompt established by SetPrompt.
179
177
const char *GetPrompt ();
180
178
181
- // / Returns the index of the line currently being edited
179
+ // / Returns the index of the line currently being edited.
182
180
uint32_t GetCurrentLine ();
183
181
184
- // / Interrupt the current edit as if ^C was pressed
182
+ // / Interrupt the current edit as if ^C was pressed.
185
183
bool Interrupt ();
186
184
187
- // / Cancel this edit and oblitarate all trace of it
185
+ // / Cancel this edit and obliterate all trace of it.
188
186
bool Cancel ();
189
187
190
188
// / Register a callback for autosuggestion.
@@ -240,28 +238,24 @@ class Editline {
240
238
241
239
private:
242
240
// / Sets the lowest line number for multi-line editing sessions. A value of
243
- // / zero suppresses
244
- // / line number printing in the prompt.
241
+ // / zero suppresses line number printing in the prompt.
245
242
void SetBaseLineNumber (int line_number);
246
243
247
244
// / Returns the complete prompt by combining the prompt or continuation prompt
248
- // / with line numbers
249
- // / as appropriate. The line index is a zero-based index into the current
250
- // / multi-line session.
245
+ // / with line numbers as appropriate. The line index is a zero-based index
246
+ // / into the current multi-line session.
251
247
std::string PromptForIndex (int line_index);
252
248
253
249
// / Sets the current line index between line edits to allow free movement
254
- // / between lines. Updates
255
- // / the prompt to match.
250
+ // / between lines. Updates the prompt to match.
256
251
void SetCurrentLine (int line_index);
257
252
258
253
// / Determines the width of the prompt in characters. The width is guaranteed
259
254
// / to be the same for all lines of the current multi-line session.
260
255
size_t GetPromptWidth ();
261
256
262
257
// / Returns true if the underlying EditLine session's keybindings are
263
- // / Emacs-based, or false if
264
- // / they are VI-based.
258
+ // / Emacs-based, or false if they are VI-based.
265
259
bool IsEmacs ();
266
260
267
261
// / Returns true if the current EditLine buffer contains nothing but spaces,
@@ -272,24 +266,21 @@ class Editline {
272
266
int GetLineIndexForLocation (CursorLocation location, int cursor_row);
273
267
274
268
// / Move the cursor from one well-established location to another using
275
- // / relative line positioning
276
- // / and absolute column positioning.
269
+ // / relative line positioning and absolute column positioning.
277
270
void MoveCursor (CursorLocation from, CursorLocation to);
278
271
279
272
// / Clear from cursor position to bottom of screen and print input lines
280
- // / including prompts, optionally
281
- // / starting from a specific line. Lines are drawn with an extra space at the
282
- // / end to reserve room for
283
- // / the rightmost cursor position.
273
+ // / including prompts, optionally starting from a specific line. Lines are
274
+ // / drawn with an extra space at the end to reserve room for the rightmost
275
+ // / cursor position.
284
276
void DisplayInput (int firstIndex = 0 );
285
277
286
278
// / Counts the number of rows a given line of content will end up occupying,
287
- // / taking into account both
288
- // / the preceding prompt and a single trailing space occupied by a cursor when
289
- // / at the end of the line.
279
+ // / taking into account both the preceding prompt and a single trailing space
280
+ // / occupied by a cursor when at the end of the line.
290
281
int CountRowsForLine (const EditLineStringType &content);
291
282
292
- // / Save the line currently being edited
283
+ // / Save the line currently being edited.
293
284
void SaveEditedLine ();
294
285
295
286
// / Replaces the current multi-line session with the next entry from history.
0 commit comments