MemoLib — Multi-Line Text Control Library
Complete functionality for creating and managing multi-line text edit controls in Plan9Basic. Ideal for text areas, notes, log viewers, code editors, and any multi-line text input. Features include line-by-line access, word wrap, scrollbars, selection, clipboard, and scroll control. 139 functions.
| Category | Count | Description |
|---|---|---|
| Error Handling | 4 | memo_error, memo_errormsg$, memo_strerror$, memo_clearerror |
| Creation & Destruction | 4 | memo# (3 overloads), memo_free |
| Text Content | 4 | text (get/set), textlength, clear# |
| Lines | 8 | linecount, line (get/set), addline#, insertline#, deleteline#, lines (get/set) |
| Word Wrap & Scrollbars | 4 | wordwrap, showscrollbars (get/set) |
| Read-Only | 2 | readonly (get/set) |
| Font Properties | 14 | fontfamily, fontsize, fontcolor, bold, italic, underline, strikeout (get/set) |
| Text Alignment | 2 | textalign (get/set) |
| Selection | 7 | selstart, sellength, seltext$, selectall#, clearselection# |
| Caret Control | 6 | caretpositionline, caretpositionpos (get/set), gotoend#, gotobegin# |
| Clipboard | 4 | copy#, cut#, paste#, deleteselection# |
| Scroll Control | 3 | scrolltop (get/set), scrolltoend# |
| Position & Size | 14 | x, y, width, height (get/set), bounds#, move#, size# |
| Alignment & Margins | 12 | align (get/set), margin#, margins#, marginleft/top/right/bottom (get/set) |
| Visibility & State | 6 | visible, enabled, opacity (get/set) |
| Focus | 5 | isfocused, setfocus#, resetfocus#, taborder (get/set) |
| Tag & Parent | 6 | tag (get/set), parent# (get/set), bringtofront#, sendtoback# |
| Events | 38 | 17 event types × set/get + clearcallbacks# |
Cross-Platform Support
| Platform | Status | Notes |
|---|---|---|
| Windows | ✅ Full Support | Win32/Win64 |
| Linux | ✅ Full Support | GTK-based |
| Android | ✅ Full Support | Mobile-optimized |
Error Handling
| Function | Signature | Description |
|---|---|---|
memo_error() | memo_error@ | Last error code (0 = no error) |
memo_errormsg$() | memo_errormsg$@ | Last error message as string |
memo_strerror$(code) | memo_strerror$@n | Description for a given error code |
memo_clearerror() | memo_clearerror@ | Clear the error state |
Numeric Values Reference
Plan9Basic does not have built-in constants. You can define your own named values for readability:
' Control alignment let ALIGN_NONE = 0 let ALIGN_TOP = 1 let ALIGN_CLIENT = 9 ' Text alignment let TEXT_CENTER = 0 let TEXT_LEFT = 1 let TEXT_RIGHT = 2
Control Alignment memo_align#
| Value | Description |
|---|---|
| 0 | None (absolute positioning) |
| 1 | Top |
| 2 | Left |
| 3 | Right |
| 4 | Bottom |
| 9 | Client (fill parent) |
Text Alignment memo_textalign#
| Value | Description |
|---|---|
| 0 | Center |
| 1 | Leading (Left for LTR languages) |
| 2 | Trailing (Right for LTR languages) |
Creation & Destruction
| Function | Signature | Description |
|---|---|---|
memo#(parent#) | memo#@# | Create memo with default size |
memo#(parent#, x, y, w, h) | memo#@#nnnn | Create with position and size |
memo#(parent#, x, y, w, h, text$) | memo#@#nnnn$ | Create with position, size, and initial text |
memo_free(mem#) | memo_free@# | Destroy memo and release resources |
' Simple creation let mem# = memo#(frm#) ' With position and size let mem# = memo#(frm#, 20, 20, 460, 300) ' With initial text let mem# = memo#(frm#, 20, 20, 460, 300, "Initial text...") ' Cleanup memo_free(mem#)
Text Content
| Function | Signature | Description |
|---|---|---|
memo_text$(mem#) | memo_text$@# | Get all text as a single string |
memo_text#(mem#, text$) | memo_text#@#$ | Set all text (replaces existing content) |
memo_textlength(mem#) | memo_textlength@# | Get text length in characters |
memo_clear#(mem#) | memo_clear#@# | Clear all text |
memo_text#(mem#, "Hello World") println "Length: " + str$(memo_textlength(mem#)) let allText$ = memo_text$(mem#) memo_clear#(mem#)
Lines
MemoLib provides line-by-line access to the text content. Line indices are 0-based.
| Function | Signature | Description |
|---|---|---|
memo_linecount(mem#) | memo_linecount@# | Get total number of lines |
memo_line$(mem#, index) | memo_line$@#n | Get text of a specific line (0-based) |
memo_line#(mem#, index, text$) | memo_line#@#n$ | Set text of a specific line |
memo_addline#(mem#, text$) | memo_addline#@#$ | Append a new line at the end |
memo_insertline#(mem#, index, text$) | memo_insertline#@#n$ | Insert a new line at the given index |
memo_deleteline#(mem#, index) | memo_deleteline#@#n | Delete the line at the given index |
memo_lines$(mem#) | memo_lines$@# | Get all lines as a single string (preserving line structure) |
memo_lines#(mem#, text$) | memo_lines#@#$ | Set all lines from a single string |
' Build content line by line memo_addline#(mem#, "First line") memo_addline#(mem#, "Second line") memo_addline#(mem#, "Third line") ' Read a specific line println "Line 0: " + memo_line$(mem#, 0) ' Modify a line memo_line#(mem#, 1, "Modified second line") ' Insert at position memo_insertline#(mem#, 1, "Inserted between first and second") ' Delete a line memo_deleteline#(mem#, 2) println "Total lines: " + str$(memo_linecount(mem#))
Word Wrap & Scrollbars
| Function | Signature | Description |
|---|---|---|
memo_wordwrap(mem#) | memo_wordwrap@# | Get word wrap state (0/1) |
memo_wordwrap#(mem#, n) | memo_wordwrap#@#n | Enable/disable word wrap |
memo_showscrollbars(mem#) | memo_showscrollbars@# | Get scrollbar visibility (0/1) |
memo_showscrollbars#(mem#, n) | memo_showscrollbars#@#n | Show/hide scrollbars |
' Text editor style: no wrap, with scrollbars memo_wordwrap#(mem#, 0) memo_showscrollbars#(mem#, 1) ' Notes style: wrap text, hide scrollbars memo_wordwrap#(mem#, 1) memo_showscrollbars#(mem#, 0)
Read-Only
| Function | Signature | Description |
|---|---|---|
memo_readonly(mem#) | memo_readonly@# | Get read-only state (0/1) |
memo_readonly#(mem#, n) | memo_readonly#@#n | Enable/disable read-only mode |
' Log viewer: read-only, programmatic content only memo_readonly#(mem#, 1) memo_addline#(mem#, "[INFO] Application started")
memo_text#, memo_addline#, etc.Font Properties
| Function | Signature | Description |
|---|---|---|
memo_fontfamily$(mem#) | memo_fontfamily$@# | Get font family name |
memo_fontfamily#(mem#, family$) | memo_fontfamily#@#$ | Set font family |
memo_fontsize(mem#) | memo_fontsize@# | Get font size |
memo_fontsize#(mem#, size) | memo_fontsize#@#n | Set font size |
memo_fontcolor$(mem#) | memo_fontcolor$@# | Get font color |
memo_fontcolor#(mem#, color$) | memo_fontcolor#@#$ | Set font color |
memo_bold(mem#) | memo_bold@# | Get bold state (0/1) |
memo_bold#(mem#, n) | memo_bold#@#n | Set bold (0/1) |
memo_italic(mem#) | memo_italic@# | Get italic state (0/1) |
memo_italic#(mem#, n) | memo_italic#@#n | Set italic (0/1) |
memo_underline(mem#) | memo_underline@# | Get underline state (0/1) |
memo_underline#(mem#, n) | memo_underline#@#n | Set underline (0/1) |
memo_strikeout(mem#) | memo_strikeout@# | Get strikeout state (0/1) |
memo_strikeout#(mem#, n) | memo_strikeout#@#n | Set strikeout (0/1) |
' Code editor font memo_fontfamily#(mem#, "Consolas") memo_fontsize#(mem#, 13) memo_fontcolor#(mem#, "#333333") ' Notes font memo_fontfamily#(mem#, "Arial") memo_fontsize#(mem#, 14)
Text Alignment
| Function | Signature | Description |
|---|---|---|
memo_textalign(mem#) | memo_textalign@# | Get text alignment (0=center, 1=left, 2=right) |
memo_textalign#(mem#, n) | memo_textalign#@#n | Set text alignment |
memo_textalign#(mem#, 1) ' Left-aligned (default for most uses)
Selection
| Function | Signature | Description |
|---|---|---|
memo_selstart(mem#) | memo_selstart@# | Get selection start position (0-based) |
memo_selstart#(mem#, pos) | memo_selstart#@#n | Set selection start position |
memo_sellength(mem#) | memo_sellength@# | Get selection length |
memo_sellength#(mem#, len) | memo_sellength#@#n | Set selection length |
memo_seltext$(mem#) | memo_seltext$@# | Get the currently selected text |
memo_selectall#(mem#) | memo_selectall#@# | Select all text |
memo_clearselection#(mem#) | memo_clearselection#@# | Clear the current selection |
' Select all and read memo_selectall#(mem#) println "Selected: " + memo_seltext$(mem#) ' Programmatic selection memo_selstart#(mem#, 0) memo_sellength#(mem#, 10) ' Select first 10 characters
Caret Control
The memo has a two-dimensional caret: a line number and a character position within the entire text.
| Function | Signature | Description |
|---|---|---|
memo_caretpositionline(mem#) | memo_caretpositionline@# | Get caret line number (0-based) |
memo_caretpositionline#(mem#, line) | memo_caretpositionline#@#n | Set caret to a specific line |
memo_caretpositionpos(mem#) | memo_caretpositionpos@# | Get caret character position in full text |
memo_caretpositionpos#(mem#, pos) | memo_caretpositionpos#@#n | Set caret character position |
memo_gotoend#(mem#) | memo_gotoend#@# | Move caret to the end of text |
memo_gotobegin#(mem#) | memo_gotobegin#@# | Move caret to the beginning of text |
' Display current line in a status label let line = memo_caretpositionline(mem#) label_text#(lblStatus#, "Line: " + str$(line + 1)) ' Jump to line 10 memo_caretpositionline#(mem#, 10) ' Jump to end memo_gotoend#(mem#)
Clipboard
| Function | Signature | Description |
|---|---|---|
memo_copy#(mem#) | memo_copy#@# | Copy selected text to clipboard |
memo_cut#(mem#) | memo_cut#@# | Cut selected text to clipboard |
memo_paste#(mem#) | memo_paste#@# | Paste from clipboard at caret position |
memo_deleteselection#(mem#) | memo_deleteselection#@# | Delete the selected text without copying |
' Edit menu operations memo_selectall#(mem#) memo_copy#(mem#) ' Or cut memo_cut#(mem#) ' Paste memo_paste#(mem#)
Scroll Control
| Function | Signature | Description |
|---|---|---|
memo_scrolltop(mem#) | memo_scrolltop@# | Get vertical scroll position (pixels from top) |
memo_scrolltop#(mem#, n) | memo_scrolltop#@#n | Set vertical scroll position |
memo_scrolltoend#(mem#) | memo_scrolltoend#@# | Scroll to the end of text (show last lines) |
' Auto-scroll log after adding entries memo_addline#(mem#, "[INFO] New event logged") memo_scrolltoend#(mem#) ' Read scroll position println "Scroll: " + str$(memo_scrolltop(mem#)) + "px"
memo_scrolltoend# is essential for log viewers — call it after memo_addline# to keep the latest entry visible.Position & Size
| Function | Signature | Description |
|---|---|---|
memo_x(mem#) | memo_x@# | Get X position |
memo_x#(mem#, x) | memo_x#@#n | Set X position |
memo_y(mem#) | memo_y@# | Get Y position |
memo_y#(mem#, y) | memo_y#@#n | Set Y position |
memo_width(mem#) | memo_width@# | Get width |
memo_width#(mem#, w) | memo_width#@#n | Set width |
memo_height(mem#) | memo_height@# | Get height |
memo_height#(mem#, h) | memo_height#@#n | Set height |
memo_bounds#(mem#, x, y, w, h) | memo_bounds#@#nnnn | Set position and size in one call |
memo_move#(mem#, x, y) | memo_move#@#nn | Set position only |
memo_size#(mem#, w, h) | memo_size#@#nn | Set size only |
memo_bounds#(mem#, 10, 50, 480, 300) ' Or separately memo_move#(mem#, 10, 50) memo_size#(mem#, 480, 300)
Alignment & Margins
| Function | Signature | Description |
|---|---|---|
memo_align(mem#) | memo_align@# | Get control alignment mode |
memo_align#(mem#, n) | memo_align#@#n | Set control alignment (0=none, 1=top, 2=left, 3=right, 4=bottom, 9=client) |
memo_margin#(mem#, n) | memo_margin#@#n | Set uniform margin on all four sides |
memo_margins#(mem#, l, t, r, b) | memo_margins#@#nnnn | Set individual margins (left, top, right, bottom) |
memo_marginleft(mem#) | memo_marginleft@# | Get left margin |
memo_marginleft#(mem#, n) | memo_marginleft#@#n | Set left margin |
memo_margintop(mem#) | memo_margintop@# | Get top margin |
memo_margintop#(mem#, n) | memo_margintop#@#n | Set top margin |
memo_marginright(mem#) | memo_marginright@# | Get right margin |
memo_marginright#(mem#, n) | memo_marginright#@#n | Set right margin |
memo_marginbottom(mem#) | memo_marginbottom@# | Get bottom margin |
memo_marginbottom#(mem#, n) | memo_marginbottom#@#n | Set bottom margin |
' Fill the entire form below a toolbar memo_align#(mem#, 9) ' Client = fill remaining space memo_margin#(mem#, 5) ' 5px spacing
Visibility & State
| Function | Signature | Description |
|---|---|---|
memo_visible(mem#) | memo_visible@# | Get visibility (0/1) |
memo_visible#(mem#, n) | memo_visible#@#n | Set visibility (0=hidden, 1=visible) |
memo_enabled(mem#) | memo_enabled@# | Get enabled state (0/1) |
memo_enabled#(mem#, n) | memo_enabled#@#n | Set enabled state (0=disabled/grayed, 1=enabled) |
memo_opacity(mem#) | memo_opacity@# | Get opacity (0.0–1.0) |
memo_opacity#(mem#, value) | memo_opacity#@#n | Set opacity (0.0=transparent, 1.0=opaque) |
Focus
| Function | Signature | Description |
|---|---|---|
memo_isfocused(mem#) | memo_isfocused@# | Is this memo focused? (0/1) |
memo_setfocus#(mem#) | memo_setfocus#@# | Give keyboard focus to this memo |
memo_resetfocus#(mem#) | memo_resetfocus#@# | Release focus from this memo |
memo_taborder(mem#) | memo_taborder@# | Get tab order index |
memo_taborder#(mem#, n) | memo_taborder#@#n | Set tab order index |
Tag & Parent
| Function | Signature | Description |
|---|---|---|
memo_tag(mem#) | memo_tag@# | Get user-defined integer tag |
memo_tag#(mem#, n) | memo_tag#@#n | Set user-defined integer tag |
memo_parent#(mem#) | memo_parent#@# | Get parent control pointer |
memo_parent#(mem#, parent#) | memo_parent#@## | Move memo to a different parent |
memo_bringtofront#(mem#) | memo_bringtofront#@# | Bring to front of Z-order |
memo_sendtoback#(mem#) | memo_sendtoback#@# | Send to back of Z-order |
Events
Each event has a setter (memo_onXXX#(mem#, func$)) and a getter (memo_onXXX$(mem#)). Use memo_clearcallbacks#(mem#) to disconnect all callbacks at once.
Text Events
| Event Setter | Getter | Callback Signature | When It Fires |
|---|---|---|---|
memo_onchange#(mem#, func$) | memo_onchange$(mem#) | function name(sender#) | When editing is complete (focus lost) |
memo_onchangetracking#(mem#, func$) | memo_onchangetracking$(mem#) | function name(sender#) | On every keystroke (real-time) |
memo_onchange# for final validation. Use memo_onchangetracking# for live statistics (line count, character count) but keep the callback lightweight.Focus & Click Events
| Event Setter | Getter | Callback Signature |
|---|---|---|
memo_onenter#(mem#, func$) | memo_onenter$(mem#) | function name(sender#) |
memo_onexit#(mem#, func$) | memo_onexit$(mem#) | function name(sender#) |
memo_onclick#(mem#, func$) | memo_onclick$(mem#) | function name(sender#) |
memo_ondblclick#(mem#, func$) | memo_ondblclick$(mem#) | function name(sender#) |
Keyboard Events
| Event Setter | Getter | Callback Signature |
|---|---|---|
memo_onkeydown#(mem#, func$) | memo_onkeydown$(mem#) | function name(sender#, key, keychar$, shift$) |
memo_onkeyup#(mem#, func$) | memo_onkeyup$(mem#) | function name(sender#, key, keychar$, shift$) |
Mouse Events
| Event Setter | Getter | Callback Signature |
|---|---|---|
memo_onmousedown#(mem#, func$) | memo_onmousedown$(mem#) | function name(sender#, button, x, y, shift$) |
memo_onmouseup#(mem#, func$) | memo_onmouseup$(mem#) | function name(sender#, button, x, y, shift$) |
memo_onmousemove#(mem#, func$) | memo_onmousemove$(mem#) | function name(sender#, x, y, shift$) |
memo_onmouseenter#(mem#, func$) | memo_onmouseenter$(mem#) | function name(sender#) |
memo_onmouseleave#(mem#, func$) | memo_onmouseleave$(mem#) | function name(sender#) |
Other Events
| Event Setter | Getter | Callback Signature |
|---|---|---|
memo_onresize#(mem#, func$) | memo_onresize$(mem#) | function name(sender#) |
memo_ondragenter#(mem#, func$) | memo_ondragenter$(mem#) | function name(sender#) |
memo_ondragover#(mem#, func$) | memo_ondragover$(mem#) | function name(sender#) |
memo_ondragdrop#(mem#, func$) | memo_ondragdrop$(mem#) | function name(sender#) |
memo_ondragleave#(mem#, func$) | memo_ondragleave$(mem#) | function name(sender#) |
memo_clearcallbacks#(mem#) | — | Disconnect all event callbacks |
Complete Examples
Simple Text Editor
function OnNew(sender#) memo_clear#(mem#) label_text#(lblStatus#, "New document") endfunction function OnCopy(sender#) memo_copy#(mem#) label_text#(lblStatus#, "Copied to clipboard") endfunction function OnPaste(sender#) memo_paste#(mem#) label_text#(lblStatus#, "Pasted from clipboard") endfunction function OnSelectAll(sender#) memo_selectall#(mem#) label_text#(lblStatus#, "All text selected") endfunction function OnTextChange(sender#) local lines, chars lines = memo_linecount(sender#) chars = memo_textlength(sender#) label_text#(lblStatus#, "Lines: " + str$(lines) + " | Chars: " + str$(chars)) endfunction let frm# = form#("Text Editor", 500, 420) form_position#(frm#, 4) let mem# = memo#(frm#, 10, 50, 480, 310) memo_wordwrap#(mem#, 1) memo_fontsize#(mem#, 13) let lblStatus# = label#(frm#, "Ready") label_bounds#(lblStatus#, 10, 375, 480, 20) let btnNew# = button#(frm#, "New", 10, 10, 70, 30) let btnCopy# = button#(frm#, "Copy", 90, 10, 70, 30) let btnPaste# = button#(frm#, "Paste", 170, 10, 70, 30) let btnSelectAll# = button#(frm#, "Select All", 250, 10, 90, 30) button_onclick#(btnNew#, "OnNew") button_onclick#(btnCopy#, "OnCopy") button_onclick#(btnPaste#, "OnPaste") button_onclick#(btnSelectAll#, "OnSelectAll") memo_onchangetracking#(mem#, "OnTextChange") form_show(frm#) while form_visible(frm#) = 1 processmessages() end while
Log Viewer (Read-Only)
function OnAddLog(sender#) local ts$ ts$ = formatdatetime$("yyyy-mm-dd hh:nn:ss", now()) memo_addline#(mem#, "[" + ts$ + "] Log entry added") memo_scrolltoend#(mem#) endfunction function OnClear(sender#) memo_clear#(mem#) endfunction let frm# = form#("Log Viewer", 600, 400) form_position#(frm#, 4) let mem# = memo#(frm#, 10, 10, 580, 340) memo_readonly#(mem#, 1) memo_wordwrap#(mem#, 0) memo_fontfamily#(mem#, "Courier New") memo_fontsize#(mem#, 10) let btnAdd# = button#(frm#, "Add Log Entry", 10, 360, 120, 30) let btnClear# = button#(frm#, "Clear", 140, 360, 80, 30) button_onclick#(btnAdd#, "OnAddLog") button_onclick#(btnClear#, "OnClear") form_show(frm#) while form_visible(frm#) = 1 processmessages() end while
Code Editor with Line Tracking
function OnMemoClick(sender#) local line line = memo_caretpositionline(sender#) label_text#(lblLine#, "Line: " + str$(line + 1)) endfunction let frm# = form#("Code Editor", 700, 500) form_position#(frm#, 4) let mem# = memo#(frm#, 10, 50, 680, 400) memo_wordwrap#(mem#, 0) memo_fontfamily#(mem#, "Consolas") memo_fontsize#(mem#, 13) memo_showscrollbars#(mem#, 1) ' Sample code memo_addline#(mem#, "' Plan9Basic Sample") memo_addline#(mem#, "let x = 10") memo_addline#(mem#, "let y = 20") memo_addline#(mem#, "") memo_addline#(mem#, "function Add(a, b)") memo_addline#(mem#, " return a + b") memo_addline#(mem#, "endfunction") memo_addline#(mem#, "") memo_addline#(mem#, "println Add(x, y)") let lblLine# = label#(frm#, "Line: 1") label_move#(lblLine#, 10, 460) memo_onclick#(mem#, "OnMemoClick") form_show(frm#) while form_visible(frm#) = 1 processmessages() end while
Line Operations
function OnInsert(sender#) memo_insertline#(mem#, 1, "Inserted Line") label_text#(lblResult#, "Inserted new line at index 1") endfunction function OnDelete(sender#) if memo_linecount(mem#) > 0 then memo_deleteline#(mem#, 0) label_text#(lblResult#, "Deleted line at index 0") endif endfunction function OnGetLine(sender#) local txt$ if memo_linecount(mem#) > 0 then txt$ = memo_line$(mem#, 0) label_text#(lblResult#, "Line 0: " + txt$) endif endfunction function OnSetLine(sender#) if memo_linecount(mem#) > 0 then memo_line#(mem#, 0, "Modified Line") label_text#(lblResult#, "Line 0 modified") endif endfunction let frm# = form#("Line Operations", 500, 400) form_position#(frm#, 4) let mem# = memo#(frm#, 10, 10, 350, 300) memo_addline#(mem#, "Line 1") memo_addline#(mem#, "Line 2") memo_addline#(mem#, "Line 3") let btnInsert# = button#(frm#, "Insert at 1", 370, 10, 120, 30) let btnDelete# = button#(frm#, "Delete Line 0", 370, 50, 120, 30) let btnGetLine# = button#(frm#, "Get Line 0", 370, 90, 120, 30) let btnSetLine# = button#(frm#, "Set Line 0", 370, 130, 120, 30) let lblResult# = label#(frm#, "") label_bounds#(lblResult#, 10, 320, 480, 60) label_wordwrap#(lblResult#, 1) button_onclick#(btnInsert#, "OnInsert") button_onclick#(btnDelete#, "OnDelete") button_onclick#(btnGetLine#, "OnGetLine") button_onclick#(btnSetLine#, "OnSetLine") form_show(frm#) while form_visible(frm#) = 1 processmessages() end while
Notes with Live Statistics
function UpdateStats(sender#) local lines, chars lines = memo_linecount(sender#) chars = memo_textlength(sender#) label_text#(lblLines#, "Lines: " + str$(lines)) label_text#(lblChars#, "Characters: " + str$(chars)) endfunction let frm# = form#("Notes", 500, 380) form_position#(frm#, 4) let mem# = memo#(frm#, 10, 10, 480, 300) memo_wordwrap#(mem#, 1) let lblLines# = label#(frm#, "Lines: 1") label_move#(lblLines#, 10, 320) let lblChars# = label#(frm#, "Characters: 0") label_move#(lblChars#, 10, 345) memo_onchangetracking#(mem#, "UpdateStats") form_show(frm#) while form_visible(frm#) = 1 processmessages() end while
Best Practices
| Practice | Why |
|---|---|
Enable memo_wordwrap# for prose, disable for code | Wrapping suits notes and text; code needs horizontal scrolling |
Use memo_readonly# for log viewers | Prevents user editing while allowing programmatic updates |
| Use monospace fonts for code editors | Consolas, Courier New ensure consistent character width |
Use memo_onchangetracking# sparingly | Fires on every keystroke — keep callbacks lightweight |
Call memo_scrolltoend# after memo_addline# | Keeps the latest content visible in log-style memos |
Use memo_line$ / memo_line# for structured data | Access content by line number instead of parsing the full text |
Use memo_lines$ / memo_lines# for bulk operations | Get or set all text while preserving line structure |
Quick Reference
| Function | Signature | Description |
|---|---|---|
memo_error / errormsg$ / strerror$ / clearerror | various | Error handling (4) |
memo#(parent#[, x, y, w, h][, text$]) | various | Create memo (3 overloads) |
memo_free(mem#) | memo_free@# | Destroy memo |
memo_text$ / text# / textlength / clear# | various | Text content (4) |
memo_linecount / line$ / line# / addline# / insertline# / deleteline# / lines$ / lines# | various | Line operations (8) |
memo_wordwrap / showscrollbars | various | Wrap & scrollbars (4) |
memo_readonly | various | Read-only (2) |
memo_fontfamily / fontsize / fontcolor / bold / italic / underline / strikeout | various | Font properties (14) |
memo_textalign | memo_textalign@# / #@#n | Text alignment (2) |
memo_selstart / sellength / seltext$ / selectall# / clearselection# | various | Selection (7) |
memo_caretpositionline / caretpositionpos / gotoend# / gotobegin# | various | Caret control (6) |
memo_copy# / cut# / paste# / deleteselection# | various | Clipboard (4) |
memo_scrolltop / scrolltoend# | various | Scroll control (3) |
memo_x/y/width/height (get/set) / bounds# / move# / size# | various | Position & size (14) |
memo_align / margin# / margins# / margin[left/top/right/bottom] | various | Alignment & margins (12) |
memo_visible / enabled / opacity | various | Visibility & state (6) |
memo_isfocused / setfocus# / resetfocus# / taborder | various | Focus (5) |
memo_tag / parent# / bringtofront# / sendtoback# | various | Tag & parent (6) |
memo_onchange/onchangetracking/onenter/onexit/onclick/ondblclick/onkeydown/onkeyup/onmousedown/onmouseup/onmousemove/onmouseenter/onmouseleave/onresize/ondragenter/ondragover/ondragdrop/ondragleave | various | Events set+get (37) |
memo_clearcallbacks# | memo_clearcallbacks#@# | Disconnect all events |
139 functions. Part of the Plan9Basic GUI library system.