cmd2.pt_utils
cmd2.pt_utils
Utilities for integrating prompt_toolkit with cmd2.
BASE_DELIMITERS
module-attribute
BASE_DELIMITERS = (
" \t\n" + join(QUOTES) + join(REDIRECTION_CHARS)
)
ANSI_NAMES
module-attribute
ANSI_NAMES = (
"ansiblack",
"ansired",
"ansigreen",
"ansiyellow",
"ansiblue",
"ansimagenta",
"ansicyan",
"ansiwhite",
"ansibrightblack",
"ansibrightred",
"ansibrightgreen",
"ansibrightyellow",
"ansibrightblue",
"ansibrightmagenta",
"ansibrightcyan",
"ansibrightwhite",
)
Cmd2Completer
Bases: Completer
Completer that delegates to cmd2's completion logic.
Initialize prompt_toolkit based completer class.
Source code in cmd2/pt_utils.py
get_completions
Get completions for the current input.
Source code in cmd2/pt_utils.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
Cmd2History
Bases: History
A non-persistent, in-memory history buffer for prompt-toolkit.
This class serves as the backing store for UI history navigation (e.g., arrowing through previous commands). It explicitly avoids handling persistence, deferring all permanent storage logic to the cmd2 application.
Initialize the instance.
Source code in cmd2/pt_utils.py
append_string
Override to filter our consecutive duplicates.
Source code in cmd2/pt_utils.py
store_string
load_history_strings
Cmd2Lexer
Bases: Lexer
Lexer that highlights cmd2 command names, aliases, and macros.
Initialize the Lexer.
| PARAMETER | DESCRIPTION |
|---|---|
cmd_app
|
cmd2.Cmd instance
TYPE:
|
Source code in cmd2/pt_utils.py
lex_document
Lex the document.
Source code in cmd2/pt_utils.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
pt_filter_style
Strip styles if disallowed by ru.ALLOW_STYLE. Otherwise return an ANSI object.
This function is intended specifically for text rendered by prompt-toolkit.
Source code in cmd2/pt_utils.py
rich_to_pt_color
cached
Convert a rich Color object to a prompt_toolkit color string.
Source code in cmd2/pt_utils.py
rich_to_pt_style
cached
Convert a rich Style object to a prompt_toolkit style string.