diff options
| -rw-r--r-- | doc/architecture.md | 38 | ||||
| -rw-r--r-- | doc/cha-api.7 | 11 | ||||
| -rw-r--r-- | doc/cha-config.5 | 10 | ||||
| -rw-r--r-- | doc/cha-css.7 | 151 |
4 files changed, 187 insertions, 23 deletions
diff --git a/doc/architecture.md b/doc/architecture.md index e368addb..dcfee52d 100644 --- a/doc/architecture.md +++ b/doc/architecture.md @@ -239,6 +239,8 @@ code manually, we have JS pragmas to automagically turn Nim procedures into JavaScript functions. (For details on the specific pragmas, see the [manual](https://git.sr.ht/~bptato/monoucha/tree/master/doc/manual.md).) +(TODO: description of type conversion is somewhat outdated.) + The type conversion itself is handled by the overloaded toJS function and the generic fromJS function. toJS returns a JSValue, the native data type of QuickJS. fromJS returns a Result[T, JSError], which is @@ -337,19 +339,23 @@ CSS 3 parsing module. The latest iteration of the selector parser is pretty good. The media query parser and the CSS value parser both work OK, but are missing some commonly used features like variables. -Cascading is slow, though it could be slower. Chawan caches the style -tree, so re-styles are normally very fast. Also, a hash map is used for -reducing initial style calculation times. However, we don't have a Bloom -filter yet. +Cascading is OK. To speed up selector matching, various properties are +hashed to filter out irrelevant CSS rules. However, no further style +optimization exists yet (such as Bloom filters or style interning). + +Style calculation is incremental, and results are cached until an +element's style is invalidated, so re-styles are quite fast. (The +invalidation logic is primitive, but as far as I can tell, it's good +enough in most cases.) ### Layout -Our layout engine is a rather simple procedural layout implementation. -It runs in two passes. +Our layout engine is a rather "simple" procedural layout implementation. +It runs in two passes (but I'm working on eliminating the first one.) -1. Build a layout tree. Anonymous boxes are generated here. After this - pass, the tree is no longer mutated, only the `state` and `render` - fields of the respective boxes. +1. Build a layout tree. Anonymous block and table boxes are generated + here. After this pass, the tree is no longer mutated, only the + `state` and `render` fields of the respective boxes. 2. Position said boxes, always relative to their parent. This pass sets the values in the `state` field. @@ -360,26 +366,24 @@ the entire sub-layout is skipped if the sizes remained identical. (This usually happens if a box's inner layout does not depend on its parent box's sizes at all, e.g. with a non-percentage specified width.) -Layout is fully recursive. This means that after a certain nesting -depth, the buffer will run out of stack space and promptly crash. - Since we do not cache layout results, and the whole page is layouted, -it gets quite slow on large documents. (Layout is being incrementally +it gets quite slow on large documents. (Layout is being incrementally refactored to make implementing a cache simpler.) ### Rendering After layout is finished, the document is rendered onto a text-based canvas, which is represented as a sequence of strings associated with -their formatting. +their formatting. (Right now, "formatting" also includes a reference to +the respective DOM nodes; in the future, it won't.) Additionally, boxes are assigned an offset in the `render` field here, which is used when jumping to anchors. The entire document is rendered, and this is our main performance -bottleneck right now. (In fact, rendering takes much longer than -layout. Styling is even slower, but that's less of a problem because -it's cached.) +bottleneck right now. (In fact, rendering takes much longer than +layout. Styling is even slower, but that's less of a problem because it +only happens once for most elements.) The positive side of this design is that search is very simple (and fast), since we are just running regexes over a linear sequence of diff --git a/doc/cha-api.7 b/doc/cha-api.7 index 86906378..90f88efe 100644 --- a/doc/cha-api.7 +++ b/doc/cha-api.7 @@ -687,6 +687,17 @@ Save the source of this buffer. T}@T{ T} T{ +\f[CR]setCursorX(x)\f[R], \f[CR]setCursorY(y)\f[R], +\f[CR]setCursorXY(x, y)\f[R], \f[CR]setCursorXCenter(x)\f[R], +\f[CR]setCursorYCenter(y)\f[R], \f[CR]setCursorXYCenter(x, y)\f[R] +T}@T{ +Set the cursor position to \f[CR]x\f[R] and \f[CR]y\f[R] respectively, +scrolling the view if necessary. +Variants that end with \[lq]Center\[rq] will also center the screen +around the position if it is outside the screen. +T}@T{ +T} +T{ \f[CR]url\f[R] T}@T{ Getter for the buffer\[cq]s URL. diff --git a/doc/cha-config.5 b/doc/cha-config.5 index a0d08989..3026a56f 100644 --- a/doc/cha-config.5 +++ b/doc/cha-config.5 @@ -1849,6 +1849,16 @@ the page. T}@T{ T} T{ +T}@T{ +, None +T}@T{ +\f[CR]cmd.buffer.gotoColumnOrBegin\f[R], +\f[CR]cmd.buffer.gotoColumnOrEnd\f[R] +T}@T{ +If n is specified, jump to column n of the current line. +Otherwise, jump to the first/last column. +T} +T{ m T}@T{ \f[CR]cmd.buffer.mark\f[R] diff --git a/doc/cha-css.7 b/doc/cha-css.7 index d91c93e3..a5dae13b 100644 --- a/doc/cha-css.7 +++ b/doc/cha-css.7 @@ -2,14 +2,153 @@ .\" .TH "cha\-css" "7" "" "" "Image support in Chawan" .SH CSS in Chawan -This document describes some proprietary CSS extensions supported by -Chawan, as well as its intentional deviations from standards. +This document describes CSS properties supported by Chawan, as well as +its proprietary extensions and deviations from standards. .PP -If you discover a deviation that is not covered by this document, then -please open a ticket at \c +If you discover a deviation that is not covered by this document, please +open a ticket at \c .UR https://todo.sr.ht/~bptato/chawan .UE \c \&. +.SS Standard properties +A list of supported standard properties, with notes on unimplemented +values: +.IP \[bu] 2 +background\-color (see color) +.IP \[bu] 2 +background\-image (displays placeholders only) +.IP \[bu] 2 +border\-collapse +.IP \[bu] 2 +border\-spacing +.IP \[bu] 2 +bottom +.IP \[bu] 2 +box\-sizing +.IP \[bu] 2 +caption\-side +.IP \[bu] 2 +clear +.IP \[bu] 2 +color (hex values and functions \f[CR]rgb\f[R], \f[CR]rgba\f[R], +\f[CR]hsl\f[R], \f[CR]hsla\f[R]) +.IP \[bu] 2 +content +.IP \[bu] 2 +counter\-reset +.IP \[bu] 2 +display (\f[CR]block\f[R], \f[CR]inline\-block\f[R], +\f[CR]list\-item\f[R], \f[CR]table\f[R], \f[CR]table\-*\f[R], +\f[CR]flex\f[R], \f[CR]inline\-flex\f[R], \f[CR]flow\-root\f[R]) +.IP \[bu] 2 +flex\-basis (but \f[CR]content\f[R] not supported) +.IP \[bu] 2 +flex\-direction +.IP \[bu] 2 +flex\-grow +.IP \[bu] 2 +flex\-shrink +.IP \[bu] 2 +flex\-wrap +.IP \[bu] 2 +float +.IP \[bu] 2 +font\-size (ignored; only for JS compatibility) +.IP \[bu] 2 +font\-style (\f[CR]oblique\f[R] interpreted as \f[CR]italic\f[R]) +.IP \[bu] 2 +font\-weight (numeric properties > 500 interpreted as bold, others as +regular) +.IP \[bu] 2 +height +.IP \[bu] 2 +left +.IP \[bu] 2 +list\-style\-position +.IP \[bu] 2 +list\-style\-type (but no custom list styles) +.IP \[bu] 2 +margin\-bottom +.IP \[bu] 2 +margin\-left +.IP \[bu] 2 +margin\-right +.IP \[bu] 2 +margin\-top +.IP \[bu] 2 +max\-height +.IP \[bu] 2 +max\-width +.IP \[bu] 2 +min\-height +.IP \[bu] 2 +min\-width +.IP \[bu] 2 +opacity (hacky; only works with \f[CR]opacity: 0\f[R]) +.IP \[bu] 2 +overflow\-x (see below on scrollbars) +.IP \[bu] 2 +overflow\-y (see below on scrollbars) +.IP \[bu] 2 +padding\-bottom +.IP \[bu] 2 +padding\-left +.IP \[bu] 2 +padding\-right +.IP \[bu] 2 +padding\-top +.IP \[bu] 2 +position (see below for \f[CR]sticky\f[R] and \f[CR]fixed\f[R]) +.IP \[bu] 2 +quotes +.IP \[bu] 2 +right +.IP \[bu] 2 +text\-align +.IP \[bu] 2 +text\-decoration (\f[CR]none\f[R], \f[CR]underline\f[R], +\f[CR]overline\f[R], \f[CR]line\-through\f[R]) +.IP \[bu] 2 +text\-transform +.IP \[bu] 2 +top +.IP \[bu] 2 +vertical\-align +.IP \[bu] 2 +visibility +.IP \[bu] 2 +white\-space +.IP \[bu] 2 +width +.IP \[bu] 2 +word\-break +.IP \[bu] 2 +z\-index (negative values are not respected yet) +.PP +Shorthands: +.IP \[bu] 2 +all +.IP \[bu] 2 +margin +.IP \[bu] 2 +padding +.IP \[bu] 2 +background (only color and url; other components are skipped) +.IP \[bu] 2 +list\-style (list\-style\-image is skipped) +.IP \[bu] 2 +flex +.IP \[bu] 2 +flex\-flow +.IP \[bu] 2 +overflow +.PP +Variables (the \f[CR]var\f[R] function) are supported only for +non\-shorthand properties and the \f[CR]background\f[R] shorthand. +.PP +Values with a \f[CR]<length>\f[R] type support very simple +\f[CR]calc()\f[R] expressions that consist of one addition or +subtraction and do not use the \f[CR]var\f[R] function. .SS Proprietary extensions .IP \[bu] 2 \f[CR]text\-align\f[R] accepts the values \f[CR]\-cha\-center\f[R], @@ -62,8 +201,8 @@ screen. .SS User agent style sheet The user agent style sheet is a combination of the styles suggested by the HTML standard and a CSS port of w3m\[cq]s rendering. -In general, faithfulness to w3m is preferred over the standard, unless -it breaks existing websites. +In general, faithfulness to w3m is preferred over the standard\[cq]s +suggestions, unless those break on existing websites. .PP Link colors differ depending on the terminal\[cq]s color scheme. .SS Sizing and positioning |