Notepad

A plain, predictable multi-line text editor — a Text dressed with a line-number gutter, the editing keys everyone takes for granted, and an optional Ln/Col · N chars status strip. Deliberately not an IDE: no syntax highlighting, no find-and-replace, no folding. It supports less, on purpose — classic-Notepad-style, learnable in zero seconds. Reach for Notepad when an ordinary person needs to type or read text in your app; keep Text when you want a blank canvas to configure yourself.

Live preview

Live preview. In the Player's built-in docs viewer (scriptweaver --help), this renders Notepad as a live, theme-aware widget you can interact with.

Example

const ed = app.Notepad({
  text: 'Dear team,\n\nShip the plain editor.\n',
  status: true, // show the Ln/Col · chars strip
  height: 12,
});
ed.pack.configure({ fill: 'both', expand: true });

ed.onEdit(() => console.log('changed:', ed.cursorInfo().chars, 'chars'));

// Load / read the whole buffer:
ed.value = 'Replaced text'; // (also: ed.setText(…))
console.log(ed.value); // (also: ed.getText())

Predictable keys

The keys a Windows-mental-model user expects are always on (a bare Text surprisingly binds select-all to Ctrl+/ only, and leaves undo off):

Keys Action
Ctrl+A Select all
Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z Undo / redo (undo is on by default)
Ctrl+C / Ctrl+X / Ctrl+V Copy / cut / paste
Ctrl+Backspace Delete the previous word

Nothing else. The emacs-style editing keys a plain Text also binds — Ctrl+K (kill line), Ctrl+O, Ctrl+T, Ctrl+D — are suppressed, because on a Windows-style keyboard they silently destroy text and classic Notepad has none of them. That restraint is the feature.

Load vs. edit. Setting the whole buffer — setText(s), value = s, or the text option — loads a document: it replaces the content and resets the undo stack (so Ctrl+Z can't wipe freshly loaded text), and does not fire onEdit. Fine-grained insert/delete and the user's own typing are edits, and do fire it.

Methods

The full Text surface works directly on the widget — insert/ get/delete/clear, see/index, the tag* helpers — plus:

Method Description
getText() / setText(s) Get or load the whole buffer (see the note above).
value Property form of the above: ed.value gets, ed.value = s loads.
cursorInfo() { line, col, chars } for the current insertion point — col is 1-based, chars is the buffer length (excluding the trailing newline). Drives a status readout.
insert(index, s) / delete(from, to) Text passthrough for fine-grained edits (these fire onEdit).
focus() Give the editor keyboard focus.

Events

Register with the onEdit / onCursor options, or as on… methods (ed.onEdit(fn)). Handlers are notifications — they receive no argument; read the current state from the widget (ed.value, ed.cursorInfo()).

Event Fires when
onEdit The content changed (typed or programmatic insert/delete; not a whole-buffer load).
onCursor The insertion point or selection moved — pair it with cursorInfo() for a live Ln/Col readout.

Options

Option Type Description
text string Initial content. Also the get/set accessor for the whole buffer (setting it loads a document — see the note above).
monospace boolean Use a fixed-width font. Default false (the theme's proportional text font).
lineNumbers boolean Show the scroll-synced line-number gutter. Default true.
wrap string 'none' (default) or 'word'. Word-wrap can't align a per-line gutter, so 'word' turns lineNumbers off.
readOnly boolean Viewer mode: the text stays selectable and copyable, but not editable. Default false.
status boolean Show a built-in Ln x, Col y · N chars strip along the bottom. Default false.
width number Width in characters.
height number Height in lines.
state string 'normal' (default) or 'disabled'.
font string Override the editor font (the gutter follows it). Usually just set monospace.
cursor string The mouse cursor over the editor.
style string ttk style for the outer frame. Defaults to the bordered Notepad.TFrame; override to restyle or remove the border.
padding string Internal padding between the frame border and the editor, e.g. '4' or '4 8'. Defaults to a small inset that reveals the border.
onEdit function Content-changed handler (see Events).
onCursor function Cursor/selection-moved handler (see Events).

See also