Skip to content

Claude's answers, rendered: Markdown, math, charts and diagrams drawn in the Claude Code terminal. Independent project, not affiliated with Anthropic.

TypeScript claude-code-mod

Grid: on by default; /iui grid off for the usual spacing

razorback16641fff36d05a
diff --git a/README.md b/README.md
index 8c9139d..9883fb5 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,7 @@ More in the [gallery](docs/gallery.md): plots, fractals and a tour of all the Ma
| `/iui on` / `off` | Turns the pictures on or off |
| `/iui theme <name>` | Changes the theme: `claude-code`, `vscode-modern`, `vscode` or your own |
| `/iui size <80–200>` | Text size in percent of your terminal text |
-| `/iui grid on` / `off` | Puts each line of text on the terminal rows, so that a mouse selection covers the text (off by default) |
+| `/iui grid on` / `off` | Puts each line of text on the terminal rows, so that a mouse selection covers the text (on by default) |
| `/iui updates on` / `off` | Turns the daily check for a new version on or off (on by default) |
| `/iui details` | Shows the terminal, font, mode and Typst that the mod found |
| `/iui setup` | iTerm2: adds the shell line that turns pictures on |
diff --git a/docs/usage.md b/docs/usage.md
index f649886..1ab2394 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -46,8 +46,8 @@ Intelligent UI draws Claude's answers as rendered Markdown pictures. Only the dr
| `/iui height full` | An image uses the terminal height less 16 rows (kept for later sessions). The 16 rows are for the row of the file, the text around it and the prompt. |
| `/iui height <6–200>` | Sets the most rows that an image can use (kept for later sessions). An image is never taller than with `full`. |
| `/iui grid` | Shows the row grid setting: on or off |
-| `/iui grid on` | Puts each line of text in a picture on the terminal rows (kept for later sessions). Refer to [Selection and the row grid](#selection-and-the-row-grid). |
-| `/iui grid off` | Lines of text in a picture have the usual spacing (kept for later sessions). This is the default. |
+| `/iui grid on` | Puts each line of text in a picture on the terminal rows (kept for later sessions). This is the default. Refer to [Selection and the row grid](#selection-and-the-row-grid). |
+| `/iui grid off` | Lines of text in a picture have the usual spacing (kept for later sessions). |
| `/iui updates` | Shows the update check: on or off, and the newest version that it found |
| `/iui updates on` | Looks for a new version one time each day at most, and shows a toast when there is one (kept for later sessions). This is the default. Refer to [Update](install.md#update). |
| `/iui updates off` | Stops the check for a new version and its toast (kept for later sessions) |
@@ -86,9 +86,9 @@ For the limits, refer to [Limitations](limitations.md).
## Selection and the row grid
-The terminal draws a mouse selection as full cells, thus a selection covers full rows. Usually, the lines of text in a picture are not on the terminal rows. A line of body text is approximately 1.3 rows tall, and a line in a list or a table is approximately 1.6 rows tall. Thus, after some lines, the selection is not on the text that the mod copies.
+The terminal draws a mouse selection as full cells, thus a selection covers full rows. Without the grid, the lines of text in a picture are not on the terminal rows. A line of body text is approximately 1.3 rows tall, and a line in a list or a table is approximately 1.6 rows tall. Thus, after some lines, the selection is not on the text that the mod copies.
-`/iui grid on` puts each line of text on the terminal rows:
+The row grid (`/iui grid on`, the default) puts each line of text on the terminal rows:
- Each line of body text, a list, a quote or a table uses one row (or more rows if the text is large). The middle of the text is in the middle of a row.
- Each heading, each code line and each gap between blocks uses full rows.
@@ -98,7 +98,7 @@ The terminal draws a mouse selection as full cells, thus a selection covers full
- The reply bullet is on the row that holds the middle of the first line. For example, the bullet is on the second row of a level-1 heading.
- Some blocks have a height that the mod cannot set, for example display math, an image or a Typst drawing. The mod adds space to such a block, so that its height is a number of full rows.
-Thus the selection covers the text that the mod copies. The lines are closer together than without the grid, so the look is not the same as VS Code. The grid is off by default. For the limits, refer to [Limitations](limitations.md).
+Thus the selection covers the text that the mod copies. The lines are closer together than without the grid, so the look is not the same as VS Code. The grid is on by default. Use `/iui grid off` for the usual spacing. For the limits, refer to [Limitations](limitations.md).
## Plan approval
diff --git a/hooks/lib/command.ts b/hooks/lib/command.ts
index efc87f1..ed0ba4f 100644
--- a/hooks/lib/command.ts
+++ b/hooks/lib/command.ts
@@ -126,10 +126,10 @@ export function commandSuggestions(
description: h === height ? 'current' : h === DEFAULT_HEIGHT ? 'the default: half the terminal'
: h === 'full' ? `the terminal height less ${PICTURE_ROOM_ROWS} rows` : undefined,
}))
- const grid = o.grid ? 'on' : 'off'
+ const grid = o.grid === false ? 'off' : 'on'
const gridRows = (prefix: string, lead: string) => GRIDS
.filter(g => g.startsWith(prefix))
- .map(g => ({ text: `${lead}${g}`, label: g, description: g === grid ? 'current' : g === 'off' ? 'the default' : undefined }))
+ .map(g => ({ text: `${lead}${g}`, label: g, description: g === grid ? 'current' : g === 'on' ? 'the default' : undefined }))
const updates = o.updates === false ? 'off' : 'on'
const updateRows = (prefix: string, lead: string) => UPDATES
.filter(u => u.startsWith(prefix))
diff --git a/hooks/lib/env.ts b/hooks/lib/env.ts
index caf16c0..ffe5080 100644
--- a/hooks/lib/env.ts
+++ b/hooks/lib/env.ts
@@ -88,7 +88,7 @@ export function setUp($: EngineInterface): Promise<Env> {
const height = await storeGet($, 'height').catch(() => undefined)
S.height = height === 'half' || height === 'full' ? height
: Number.isInteger(height) && Number(height) >= MIN_HEIGHT && Number(height) <= MAX_HEIGHT ? Number(height) : DEFAULT_HEIGHT
- S.grid = (await storeGet($, 'grid').catch(() => undefined)) === true
+ S.grid = (await storeGet($, 'grid').catch(() => undefined)) !== false
if ((await storeGet($, 'enabled').catch(() => undefined)) === false) await update($, isOn, () => false).catch(() => undefined)
const isMac = os.trim() === 'Darwin'
setFrame(await readFrame($))
diff --git a/hooks/lib/settings.ts b/hooks/lib/settings.ts
index c3b0192..12a3950 100644
--- a/hooks/lib/settings.ts
+++ b/hooks/lib/settings.ts
@@ -104,7 +104,7 @@ export const heightText = (height: Height) =>
: height === 'full' ? `full (the terminal height less ${PICTURE_ROOM_ROWS} rows)`
: `${height} rows`
// The grid setting as words.
-export const gridText = (grid: boolean) => (grid ? 'on (each line of text on whole terminal rows)' : 'off (the default)')
+export const gridText = (grid: boolean) => (grid ? 'on (each line of text on whole terminal rows)' : 'off')
export const PICTURES_KEPT = 64
// The file paths of the link rows under a picture: whether each one is a
// file, kept for this many paths (the oldest go).
diff --git a/hooks/lib/state.ts b/hooks/lib/state.ts
index 6a8af65..06c1903 100644
--- a/hooks/lib/state.ts
+++ b/hooks/lib/state.ts
@@ -134,8 +134,8 @@ export const S = {
// committed (with `shown`), so an image box changes in one step.
shownHeight: DEFAULT_HEIGHT as Height,
// `/iui grid`: each text line of a page on whole terminal rows, so a
- // mouse selection (whole cells) covers the text it copies. Off by default.
- grid: false,
+ // mouse selection (whole cells) covers the text it copies. On by default.
+ grid: true,
look: null as Look | null,
// The usable themes the last scan found, for the typeahead.
themeChoices: [] as ThemeInfo[],
diff --git a/hooks/register.tsx b/hooks/register.tsx
index f5ddfcc..46300ff 100644
--- a/hooks/register.tsx
+++ b/hooks/register.tsx
@@ -511,7 +511,7 @@ export const register: Register = on => {
await storeSet($, 'grid', S.grid)
}
const head = asked.grid === undefined ? 'The row grid is' : 'The row grid is now'
- return { text: `${head} ${gridText(S.grid)}. With the grid on, a mouse selection over a picture covers the lines it copies. Use /iui grid on, or /iui grid off (the default).` }
+ return { text: `${head} ${gridText(S.grid)}. With the grid on, a mouse selection over a picture covers the lines it copies. Use /iui grid on (the default), or /iui grid off.` }
}
if (asked.kind === 'updates') {
await loadUpdates($)
diff --git a/tests/command.test.ts b/tests/command.test.ts
index 72247c5..2155e94 100644
--- a/tests/command.test.ts
+++ b/tests/command.test.ts
@@ -41,8 +41,8 @@ test('right after theme or size, rows hold the word and its argument', () => {
expect(heights[1]!.description).toBe('the terminal height less 16 rows')
const grids = at('/iui grid')
expect(grids.map(r => r.text)).toEqual(['grid on', 'grid off'])
- // off is the default; with no grid given, it is current.
- expect(grids.map(r => r.description)).toEqual([undefined, 'current'])
+ // on is the default; with no grid given, it is current.
+ expect(grids.map(r => r.description)).toEqual(['current', undefined])
})
test('a theme name or size completes after its word', () => {
@@ -63,8 +63,8 @@ test('a theme name or size completes after its word', () => {
expect(tall('/iui height h')[0]!.description).toBe('the default: half the terminal')
expect(at('/iui grid o').map(r => r.text)).toEqual(['on', 'off'])
expect(at('/iui grid of').map(r => r.label)).toEqual(['off'])
- const gridded = (text: string) => commandSuggestions(text, /\S+$/.exec(text)![0], text.lastIndexOf(' ') + 1, { ...o, grid: true })
- expect(gridded('/iui grid o').map(r => r.description)).toEqual(['current', 'the default'])
+ const gridded = (text: string) => commandSuggestions(text, /\S+$/.exec(text)![0], text.lastIndexOf(' ') + 1, { ...o, grid: false })
+ expect(gridded('/iui grid o').map(r => r.description)).toEqual(['the default', 'current'])
expect(at('/iui grid on extra')).toEqual([])
})
diff --git a/tests/draw.test.ts b/tests/draw.test.ts
index aa0b920..c37640a 100644
--- a/tests/draw.test.ts
+++ b/tests/draw.test.ts
@@ -319,7 +319,7 @@ const boxes = (tree: any): any[] =>
const bulletRowOf = (tree: any) => boxes(tree).find(b => b.props.width === 2)?.props.marginTop
test('grid on is kept and begins an epoch: another key, compiled with grid=1 and top=0; grid off goes back to the key of before', async ($, on) => {
- const { clock, kept, compiles, logs } = world(on, { TERM: 'xterm-kitty', IUI_DEBUG: '1' })
+ const { clock, kept, compiles, logs } = world(on, { TERM: 'xterm-kitty', IUI_DEBUG: '1' }, HEAD, { grid: false })
const ran = await $.command.run({ command: 'iui', args: '' } as any)
expect(ran.text).toContain('grid off.')
const ui = await $.ui.mount(message('g-1', 'Some **bold** text.'))
@@ -385,7 +385,7 @@ test('with the grid on, the bullet row comes from the grid numbers that the font
})
test('a heading with the grid off keeps its bullet row and top margin', async ($, on) => {
- const { clock, compiles } = world(on, { TERM: 'xterm-kitty' })
+ const { clock, compiles } = world(on, { TERM: 'xterm-kitty' }, HEAD, { grid: false })
await $.command.run({ command: 'iui', args: '' } as any)
const ui = await $.ui.mount(message('g-3', '# Title'))
await clock.settle()
@@ -398,10 +398,10 @@ test('a heading with the grid off keeps its bullet row and top margin', async ($
expect(bulletRowOf(await ui.drawn())).toBe(bulletRow)
})
-test('a bad kept grid is off; a bad value is refused and not kept', async ($, on) => {
+test('a bad kept grid is on (the default); a bad value is refused and not kept', async ($, on) => {
const { kept } = world(on, { TERM: 'xterm-kitty' }, HEAD, { grid: 'yes' })
const shown = await $.command.run({ command: 'iui', args: 'grid' } as any)
- expect(shown.text).toContain('The row grid is off (the default)')
+ expect(shown.text).toContain('The row grid is on (each line of text on whole terminal rows)')
const bad = await $.command.run({ command: 'iui', args: 'grid maybe' } as any)
expect(bad.text).toContain('Not understood: "grid maybe"')
expect(kept.grid).toBe(undefined)
diff --git a/tests/stream.test.ts b/tests/stream.test.ts
index 29d9401..12322e2 100644
--- a/tests/stream.test.ts
+++ b/tests/stream.test.ts
@@ -235,7 +235,7 @@ const FRAME = { columns: 100, rows: 40, cell: DEFAULT_CELL }
const keyOf = (text: string) =>
renderKey({
textHash: hashOf([text]), columns: 98, cell: DEFAULT_CELL, size: 100, mode: 'dark', termFont: '', columnPt: fontFit(DEFAULT_METRICS, 100).columnPt,
- templateStamp: '1', look: { name: DEFAULT_THEME, dir: `/mod/render/themes/${DEFAULT_THEME}`, stamp: '0' }, inline: false,
+ templateStamp: '1', look: { name: DEFAULT_THEME, dir: `/mod/render/themes/${DEFAULT_THEME}`, stamp: '0' }, inline: false, grid: S.grid,
})
const PAGE = { file: '', width: 1568, height: 64, alt: 'x', columns: 98, rows: 2 }