prompt-toolkit / prompt-toolkit/python-prompt-toolkit

How to pass formatted text to a buffer ?

Open
#711 14 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Hi,

After hours of reading the doc/code I still cannot find a way to use a buffer object with formatted text, let me explain:
In a minimalistic full screen application, I have a Window which consist in a scrollable text. Its content is being updated by another thread using buffer.insert_text() method.

I've tried a lot of solutions, even using processor, but cannot achieve to print coloured text (using HTML syntax for example)

I also tried to use a FormattedTextControl instead of a BufferControl, HTML works that way but then after the content is set at declaration, I cannot find a way to update it later.

I think I'm missing something, any clues ?

Thank you for your help

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Buffer, BufferControl, and FormattedTextControl APIs and the processor documentation. Reproduce the scrollable Window update described with buffer.insert_text() and compare it with the declaration-time FormattedTextControl example. Done means establishing and documenting a supported way to update formatted text, or clearly documenting the limitation if no such path exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.