Skip to content

Commit a75ef63

Browse files
committed
more words
1 parent cb84db5 commit a75ef63

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

docs/blog/posts/release1.0.0.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ draft: true
33
date: 2024-12-05
44
categories:
55
- Release
6-
title: "Three algorithms for high performance terminal apps"
6+
title: "Algorithms for high performance terminal apps"
77
authors:
88
- willmcgugan
99
---
@@ -20,9 +20,11 @@ I've had the fortune of being able to work fulltime on a FOSS project for the la
2020
Textual has been a constant source of programming challenges.
2121
Often frustrating but never boring, the challenges arise because the terminal "specification" says nothing about how to build a modern User Interface.
2222
The building blocks are there: after some effort you can move the cursor, write colored text, read keys and mouse movements, but that's about it.
23-
Everything else we had to build from scratch, from the most basic [button](https://textual.textualize.io/widget_gallery/#button) to a syntax highlighted [TextArea](https://textual.textualize.io/widget_gallery/#textarea), and everything along the way.
23+
Everything else we had to build from scratch. From the most basic [button](https://textual.textualize.io/widget_gallery/#button) to a syntax highlighted [TextArea](https://textual.textualize.io/widget_gallery/#textarea), and everything along the way.
2424

25-
I wanted to write-up some of the more interesting solutions we came up with, and the 1.0 milestone we just passed makes this a perfect time.
25+
I wanted to write-up some of the solutions we came up with, and the 1.0 milestone we just passed makes this a perfect time.
26+
27+
<!-- more -->
2628

2729
If you haven't followed along with Textual's development, here is a demo of what it can do.
2830
This is a Textual app, running remotely, served by your browser:
@@ -41,11 +43,10 @@ uvx --python 3.12 textual-demo
4143

4244
## The Compositor
4345

44-
The first component of Textual I want to cover is the *compositor*.
45-
The job of the compositor is to combine widgets in to a single view.
46+
The first component of Textual I want to cover is the [compositor](https://github.com/Textualize/textual/blob/main/src/textual/_compositor.py).
47+
The job of the compositor is to combine content from multiple sources into a single view.
4648

4749
We do this because the terminal itself has no notion of overlapping windows in the way a desktop does.
48-
If an app wants to display overlapping components we must first combine (or compose) them into a single update.
4950

5051
Here's a video I generated over a year ago, demonstrating the compositor:
5152

@@ -64,12 +65,11 @@ Some characters such as those in Asian languages and many emoji are double the w
6465

6566
Textual's way of handling this is inherited from [Rich](https://github.com/Textualize/rich).
6667
Anything you print in Rich, first generates a list of [Segments](https://github.com/Textualize/rich/blob/master/rich/segment.py) which consist of a string and associated style.
67-
These Segments are only converted into text with [ansi escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) at the very last moment.
68+
These Segments are only converted into text with [ansi escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) at the very end of the process.
6869

6970

70-
Textual builds its output from the same Segment object.
7171
The compositor takes lists of segments generated by widgets and further processes them, by dividing and combining, to produce the final output.
72-
In fact almost everything Textual does involves processing these segments in one way or another,.
72+
In fact almost everything Textual does involves processing these segments in one way or another.
7373

7474
!!! tip "Switch the Primitive"
7575

@@ -263,6 +263,14 @@ The useful property of this algorithm is that as the number of widgets increases
263263

264264
The code for our `SpatialMap` isn't part of the public API and therefore not in the docs, but if you are interested you can check it out here: [_spacial_map.py](https://github.com/Textualize/textual/blob/main/src/textual/_spatial_map.py).
265265

266+
## Wrapping up
267+
268+
If any of the code discussed here interests you, you have my blessing to [steal the code](./steal-this-code.md)!
269+
270+
As always, if you want to discuss this or Textual in general, we can be found on our [Discord server](https://discord.gg/Enf6Z3qhVr).
271+
272+
273+
266274
[^1]: A term I coined for the structure in Textual. There may be other unconnected things known as spatial maps.
267275
[^2]: The [grid](https://www.youtube.com/watch?v=lILHEnz8fTk&ab_channel=DaftPunk-Topic).
268276
[^3]: If you scroll the screen up, it moves *down* relative to the widgets.

0 commit comments

Comments
 (0)