LazInk: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | **LazInk** is an open-source collection of HTML and Markdown text controls for the [[Lazarus]] IDE and [[Free Pascal]]. The library provides formatted labels, editable text fields, list boxes, scrollable document viewers, and a WYSIWYG Markdown editor. | |
| 2 | 2 | ||
| 3 | 3 | Unlike conventional rich-text controls, LazInk renders its content directly onto the LCL `TCanvas`. It does not require a web browser engine, RichMemo, external rendering libraries, or widgetset-specific text backends. | |
| 4 | 4 | ||
| 5 | 5 | - **Project:** [LazInk on GitHub](https://github.com/TonyStone31/LazInk) | |
| 6 | 6 | - **Developer:** Tony Stone | |
| 7 | 7 | - **License:** BSD Zero Clause (0BSD) | |
| 8 | 8 | - **Current version:** 1.0.0.0 | |
| 9 | 9 | - **Language:** Object Pascal | |
| 10 | 10 | - **Dependencies:** Lazarus Component Library (LCL) | |
| 11 | 11 | ||
| 12 | 12 | [[File:LazInk TInkPage help site.png|thumb|420px|A help site drawn by TInkPage, in the LazInk demo]] | |
| 13 | 13 | ||
| 14 | 14 | ## Overview | |
| 15 | 15 | ||
| 16 | 16 | LazInk was developed to provide consistent, formatted text rendering across Lazarus applications without relying on platform-specific rich-text widgets. | |
| 17 | 17 | ||
| 18 | 18 | All seven controls use canvas-based drawing. The library includes its own document parsing, layout, text rendering, Markdown processing, and image decoding capabilities. | |
| 19 | 19 | ||
| 20 | 20 | LazInk supports both small pieces of inline HTML and complete documents containing headings, tables, lists, syntax-highlighted code, images, and CSS styling. | |
| 21 | 21 | ||
| 22 | 22 | A particular feature is `TInkRichEdit`, which allows users to edit formatted Markdown visually instead of editing its source syntax. | |
| 23 | 23 | ||
| 24 | 24 | ## Features | |
| 25 | 25 | ||
| 26 | 26 | - Canvas-based text rendering without an embedded browser. | |
| 27 | 27 | - HTML and GitHub Flavored Markdown support. | |
| 28 | 28 | - WYSIWYG Markdown editing. | |
| 29 | 29 | - CSS-styled HTML document rendering. | |
| 30 | 30 | - Syntax-highlighted code blocks. | |
| 31 | 31 | - PNG, animated GIF, and WebP image support. | |
| 32 | 32 | - Text selection, clipboard operations, and keyboard navigation. | |
| 33 | 33 | - Zoom and touch scrolling. | |
| 34 | 34 | - Light and dark color-scheme support. | |
| 35 | 35 | - Interactive links and document navigation. | |
| 36 | 36 | - Cross-platform architecture using the Lazarus LCL. | |
| 37 | 37 | - No third-party runtime dependencies. | |
| 38 | 38 | ||
| 39 | 39 | ## Components | |
| 40 | 40 | ||
| 41 | 41 | Installing LazInk adds seven controls to the **LazInk** component palette. | |
| 42 | 42 | ||
| 43 | 43 | | Component | Description | | |
| 44 | 44 | | -------------- | --------------------------------------------------------------------------------------------- | | |
| 45 | 45 | | `TInkLabel` | Displays a caption with inline HTML formatting, links, wrapping, and optional text selection. | | |
| 46 | 46 | | `TInkEdit` | Single-line editor supporting per-character styling, selection, and undo/redo. | | |
| 47 | 47 | | `TInkMemo` | Scrollable formatted text viewer for logs, messages, transcripts, and streaming content. | | |
| 48 | 48 | | `TInkListBox` | List box displaying formatted text with selectable and editable entries. | | |
| 49 | 49 | | `TInkRichEdit` | WYSIWYG rich-text editor supporting Markdown input and output. | | |
| 50 | 50 | | `TInkCodeMemo` | Plain multiline editor with optional character styling and automatic height adjustment. | | |
| 51 | 51 | | `TInkPage` | Complete HTML and Markdown document viewer with CSS, images, links, and navigation. | | |
| 52 | 52 | ||
| 53 | 53 | ### TInkLabel | |
| 54 | 54 | ||
| 55 | + | [[File:LazInk TInkLabel and TInkEdit.png|thumb|380px|TInkLabel, TInkEdit and TInkCodeMemo]] | |
| 56 | + | ||
| 55 | 57 | `TInkLabel` is an alternative to `TLabel` for applications requiring formatted captions. | |
| 56 | 58 | ||
| 57 | 59 | It supports inline HTML markup, including font styling, foreground and background colors, links, and text decoration. | |
| 58 | 60 | ||
| 59 | 61 | ```pascal | |
| 60 | 62 | InkLabel1.Caption := | |
| 61 | 63 | 'Status: <b><font color="#00AA00">Connected</font></b>'; | |
| 62 | 64 | ``` | |
| 63 | 65 | ||
| 64 | 66 | Additional features include word wrapping, automatic sizing, alignment, ellipsis handling, and optional text selection. | |
| 65 | 67 | ||
| 66 | - | ||
| 67 | - | ||
| 68 | 68 | ### TInkMemo | |
| 69 | 69 | ||
| 70 | + | [[File:LazInk TInkMemo.png|thumb|380px|TInkMemo]] | |
| 71 | + | ||
| 70 | 72 | `TInkMemo` displays formatted text in a scrollable control. | |
| 71 | 73 | ||
| 72 | 74 | It is useful for application logs, chat interfaces, debugging output, and other situations where formatted entries are added dynamically. | |
| 73 | 75 | ||
| 74 | 76 | ```pascal | |
| 75 | 77 | InkMemo1.TextFormat := itfMarkdown; | |
| 76 | 78 | InkMemo1.Append('**12:04** Build finished, `0 errors`'); | |
| 77 | 79 | ``` | |
| 78 | 80 | ||
| 79 | 81 | The `AppendBlock` method can insert complete formatted messages, including lists, tables, and highlighted code. | |
| 80 | 82 | ||
| 81 | 83 | `ReplaceLast` allows applications to update the most recent message as additional content arrives, making the control useful for streaming AI responses. | |
| 82 | 84 | ||
| 83 | - | ||
| 84 | - | ||
| 85 | 85 | ### TInkRichEdit | |
| 86 | 86 | ||
| 87 | + | [[File:LazInk TInkRichEdit editor.png|thumb|380px|The WYSIWYG Markdown editor, TInkRichEdit]] | |
| 88 | + | ||
| 87 | 89 | `TInkRichEdit` is a WYSIWYG rich-text editor capable of reading and writing Markdown. | |
| 88 | 90 | ||
| 89 | 91 | It supports: | |
| 90 | 92 | ||
| 91 | 93 | - Bold, italic, underline, and other character formatting. | |
| 92 | 94 | - Font colors, sizes, and backgrounds. | |
| 93 | 95 | - Headings and paragraph alignment. | |
| 94 | 96 | - Nested ordered and unordered lists. | |
| 95 | 97 | - Block quotations. | |
| 96 | 98 | - Tables. | |
| 97 | 99 | - Fenced code blocks. | |
| 98 | 100 | - Hyperlinks. | |
| 99 | 101 | - Undo and redo. | |
| 100 | 102 | - Search within the document. | |
| 101 | 103 | ||
| 102 | 104 | Unlike a conventional Markdown source editor, `TInkRichEdit` allows users to work directly with the rendered document. | |
| 103 | 105 | ||
| 104 | 106 | ```pascal | |
| 105 | 107 | InkRichEdit1.LoadMarkdown( | |
| 106 | 108 | '## My Document' + LineEnding + | |
| 107 | 109 | 'This is **bold** and *italic* text.' | |
| 108 | 110 | ); | |
| 109 | 111 | ``` | |
| 110 | 112 | ||
| 111 | 113 | The edited document can be retrieved as Markdown: | |
| 112 | 114 | ||
| 113 | 115 | ```pascal | |
| 114 | 116 | Memo1.Lines.Text := InkRichEdit1.AsMarkdown; | |
| 115 | 117 | ``` | |
| 116 | 118 | ||
| 117 | - | ||
| 118 | - | ||
| 119 | 119 | ### TInkPage | |
| 120 | 120 | ||
| 121 | + | [[File:LazInk Markdown source and preview.png|thumb|380px|Markdown source on the left, the page drawn from it on the right]] | |
| 122 | + | ||
| 121 | 123 | `TInkPage` is a lightweight document viewer for displaying HTML and Markdown inside Lazarus applications. | |
| 122 | 124 | ||
| 123 | 125 | ```pascal | |
| 124 | 126 | InkPage1.LoadFromFile('help/index.html'); | |
| 125 | 127 | ``` | |
| 126 | 128 | ||
| 127 | 129 | The control includes a document tree, CSS processing, layout engine, image decoding, hyperlinks, history navigation, search, text selection, and zoom. | |
| 128 | 130 | ||
| 129 | 131 | Supported content includes headings, tables, nested lists, code blocks, images, and styled document elements. | |
| 130 | 132 | ||
| 131 | 133 | CSS capabilities include selectors, the cascade, box layout, borders, backgrounds, tables, flex and grid layouts, and media queries. | |
| 132 | 134 | ||
| 133 | 135 | Unlike a web browser, `TInkPage` does not execute JavaScript. | |
| 134 | 136 | ||
| 135 | 137 | Applications can modify the document through its DOM-style API and refresh the displayed content. | |
| 136 | 138 | ||
| 137 | 139 | This makes it suitable for embedded help systems, documentation viewers, release notes, and application dashboards. | |
| 138 | 140 | ||
| 139 | - | ||
| 140 | - | ||
| 141 | 141 | ### Other controls | |
| 142 | 142 | ||
| 143 | + | [[File:LazInk TInkListBox.png|thumb|380px|TInkListBox]] | |
| 144 | + | ||
| 143 | 145 | `TInkEdit` provides a single-line text editor with per-character colors and styles supplied by an event. This can be used for syntax coloring and other character-level visual feedback. | |
| 144 | 146 | ||
| 145 | 147 | `TInkCodeMemo` is a plain multiline editor with character styling, word wrapping, undo, and automatic height adjustment. | |
| 146 | 148 | ||
| 147 | 149 | `TInkListBox` provides formatted list entries, text selection, optional alternating backgrounds, and in-place editing. | |
| 148 | 150 | ||
| 149 | - | ||
| 150 | - | ||
| 151 | 151 | ## Installation | |
| 152 | 152 | ||
| 153 | 153 | 1. Download or clone the [LazInk repository](https://github.com/TonyStone31/LazInk). | |
| 154 | 154 | 2. Open Lazarus. | |
| 155 | 155 | 3. Select **Package → Open Package File (.lpk)**. | |
| 156 | 156 | 4. Open `lazink.lpk` from the downloaded directory. | |
| 157 | 157 | 5. Compile the package. | |
| 158 | 158 | 6. Select **Use → Install**. | |
| 159 | 159 | 7. Rebuild or restart Lazarus as prompted. | |
| 160 | 160 | ||
| 161 | 161 | The components will appear on the **LazInk** tab of the component palette. | |
| 162 | 162 | ||
| 163 | 163 | ## Demonstration application | |
| 164 | 164 | ||
| 165 | 165 | The repository includes a demonstration application at: | |
| 166 | 166 | ||
| 167 | 167 | `demo/lazinkdemo.lpi` | |
| 168 | 168 | ||
| 169 | 169 | Open this project in Lazarus to explore the controls and their features. | |
| 170 | 170 | ||
| 171 | 171 | The demonstration is built using the Lazarus form designer and includes a separate tab for each component. | |
| 172 | 172 | ||
| 173 | 173 | ## Supported platforms | |
| 174 | 174 | ||
| 175 | + | [[File:LazInk TInkRichEdit on macOS.png|thumb|380px|The editor running on macOS]] | |
| 176 | + | ||
| 175 | 177 | LazInk is designed around the Lazarus LCL and avoids widgetset-specific rendering implementations. | |
| 176 | 178 | ||
| 177 | 179 | The current project documentation reports testing on: | |
| 178 | 180 | ||
| 179 | 181 | | Platform | Environment | | |
| 180 | 182 | | ------------ | ------------------------------ | | |
| 181 | 183 | | Linux x86-64 | GTK3, Lazarus trunk, FPC 3.3.1 | | |
| 182 | 184 | | macOS Intel | Cocoa, Lazarus 4.8, FPC 3.2.4 | | |
| 183 | 185 | ||
| 184 | 186 | The macOS tests were performed using macOS Sequoia 15 in an Intel virtual machine. | |
| 185 | - | ||
| 186 | - | ||
| 187 | 187 | ||
| 188 | 188 | Other Lazarus widgetsets are intended to be supported through the shared LCL drawing architecture, but compatibility should not be assumed without testing. | |
| 189 | 189 | ||
| 190 | 190 | The project is currently usable, although APIs may change as development continues. | |
| 191 | 191 | ||
| 192 | 192 | ## Documentation | |
| 193 | 193 | ||
| 194 | 194 | Additional technical documentation is available in the project repository: | |
| 195 | 195 | ||
| 196 | 196 | - [README](https://github.com/TonyStone31/LazInk/blob/master/README.md) — project overview, features, and installation. | |
| 197 | 197 | - [Complete guide](https://github.com/TonyStone31/LazInk/blob/master/docs/GUIDE.md) — detailed documentation of controls, events, properties, markup, and examples. | |
| 198 | 198 | - [HTML and CSS support](https://github.com/TonyStone31/LazInk/blob/master/docs/HTML_SUPPORT.md) — supported document elements and styling capabilities. | |
| 199 | 199 | - [Source code](https://github.com/TonyStone31/LazInk) — complete Object Pascal implementation. | |
| 200 | 200 | - [Issue tracker](https://github.com/TonyStone31/LazInk/issues) — bug reports and feature requests. | |
| 201 | 201 | ||
| 202 | 202 | ## License | |
| 203 | 203 | ||
| 204 | 204 | LazInk is released under the **BSD Zero Clause License (0BSD)**, a permissive open-source software license. | |
| 205 | 205 | ||
| 206 | 206 | Some bundled reference data and decoder tables have separate attribution requirements documented in the repository's `LICENSES/THIRD-PARTY.md`. | |
| 207 | 207 | ||
| 208 | 208 | Applications incorporating the WebP decoder through `TInkPage` should retain the applicable RFC 6386 notice as described by the project. | |
| 209 | 209 | ||
| 210 | 210 | ## See also | |
| 211 | 211 | ||
| 212 | 212 | - [[Lazarus]] | |
| 213 | 213 | - [[Lazarus Packages]] | |
| 214 | 214 | - [[How To Write Lazarus Component]] | |
| 215 | 215 | - [[Projects using Lazarus - Components and Libraries]] | |
| 216 | 216 | ||
| 217 | 217 | Category:Lazarus | |
| 218 | 218 | Category:Components |