Post-V2: Rewrite TextFormatter
#3617
Labels
design
Issues regarding Terminal.Gui design (bugs, guidelines, debates, etc...)
TextFormatter
#3617
We've discussed all of the cruft in the current
TextFormatter
design and implementation many times.This Issue is to collect all of the issues and track a re-design an re-implementation.
This Issue is marked as POST-v2 as the current implementation actually works fine for the most part and we have much bigger fish to fry. but post V2 we should tackle this.
Problems with Current
TextFormatter
Format
andDraw
are decoupled -Draw
does a significant amount of "formatting". The impact of this is getting the size of the formatted text (e.g.FormatAndGetSize()
is error prone. This is critical forDim.Auto(Text)
... and means the current implementation of that has a bunch of hacks.TextFormatter.AutoSize
is completely useless (and no longer used by the coreView
class). This is because it couples width and height (and because of the aformentionedDraw
/Format
decoupling).Performance - The current implementation is horribly inefficient and the design is such that
Format
gets called many-many times during operations likeLayoutSubviews
/SetRelativeLayout
.We now have a simple, robust, alignment engine:
Aligner
. The current implementation has a very complex, spaghetti-code, alignment/justification implementation - It is now well tested, but the unit tests for it are actually unit tests of higher-level functions, likeView.Draw
.Poor extensibility and no replicability - As @tznind noted in Gradients - From Terminal Text Effects #3586, adding gradient formatting will be a ton of work given the nature of the current code. This is an example of poor extensibility. For replicability, a possible path for addressing Support TUI apps running in the browser - aka Add HTML5 rendering support #1642 would be to have multiple
TextFormatter
implementations. E.g. one for "Attributed Text" and one for "HTML".TextFormatter.WordWrap
is fragile and confusing.(Please feel to add more!)
Great things about the current
TextFormatter
TextFormatterDemo
Scenario illustrates just how powerful the current engine is.View
,Label
, etc...), but it's not bad.Issues & PRs with valid context
TextFormatter
bugs #3418Dim.Auto (DimAutoStyle.Text)
confusesTextFormatter
whenWidth
is absoulte andHeight
is auto #3469The text was updated successfully, but these errors were encountered: