@trendr/core 0.4.7 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trendr/core",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "description": "direct-mode TUI renderer with JSX, signals, and per-cell diffing",
5
5
  "license": "MIT",
6
6
  "author": "Jonathan Pyers",
package/src/diff-view.js CHANGED
@@ -75,6 +75,7 @@ export function Diff({
75
75
  wordDiff = true,
76
76
  context = Infinity,
77
77
  lineNumbers = true,
78
+ folds = true,
78
79
  focused = true,
79
80
  scrollOffset: offsetProp,
80
81
  onScroll,
@@ -88,7 +89,11 @@ export function Diff({
88
89
  const offset = offsetProp ?? offsetInternal()
89
90
  const setOffset = onScroll ?? setOffsetInternal
90
91
 
91
- const { rows, stats } = memoComputeDiff({ before, after, patch, hunks, wordDiff, context })
92
+ const computed = memoComputeDiff({ before, after, patch, hunks, wordDiff, context })
93
+ const stats = computed.stats
94
+ // the gutter numbers already show the jump across elided regions, so a
95
+ // caller can drop the fold banners entirely
96
+ const rows = folds ? computed.rows : computed.rows.filter((r) => r.type !== 'fold')
92
97
 
93
98
  const wholeMode = hunks == null && patch == null
94
99
  const hiLines = (text) => {
package/src/text-area.js CHANGED
@@ -124,7 +124,7 @@ function ensureVisible(cursorRow, scroll, height, totalLines) {
124
124
  return scroll
125
125
  }
126
126
 
127
- export function TextArea({ onSubmit, onCancel, onChange, onKeyDown, placeholder, focused = true, maxHeight = 10, clearOnSubmit = true, cursor: cursorProp, value: valueProp, submitOnEnter = false, color }) {
127
+ export function TextArea({ onSubmit, onCancel, onChange, onKeyDown, placeholder, focused = true, maxHeight = 10, clearOnSubmit = true, cursor: cursorProp, value: valueProp, submitOnEnter = false, color, lineCounter = false }) {
128
128
  const [value, setValue] = createSignal('')
129
129
  const [cursor, setCursor] = createSignal(0)
130
130
  if (valueProp !== undefined && valueProp !== value()) {
@@ -319,7 +319,11 @@ export function TextArea({ onSubmit, onCancel, onChange, onKeyDown, placeholder,
319
319
  const lineMap = wrapForEditor(v, effectiveWidth)
320
320
  const displayPos = cursorToDisplay(c, lineMap, v)
321
321
 
322
- const displayHeight = Math.max(1, Math.min(lineMap.length, maxHeight))
322
+ // an active counter reserves the bottom row for itself so it can never
323
+ // overlap text or the cursor; overflow state costs one visible text row
324
+ const counterActive = lineCounter && lineMap.length > maxHeight
325
+ const boxMax = counterActive ? Math.max(1, maxHeight - 1) : maxHeight
326
+ const displayHeight = Math.max(1, Math.min(lineMap.length, boxMax))
323
327
  ref.scroll = ensureVisible(displayPos.row, ref.scroll, displayHeight, lineMap.length)
324
328
  const scroll = ref.scroll
325
329
 
@@ -365,8 +369,15 @@ export function TextArea({ onSubmit, onCancel, onChange, onKeyDown, placeholder,
365
369
  })
366
370
  })
367
371
 
372
+ const counter = counterActive
373
+ ? jsx('box', {
374
+ style: { flexDirection: 'row', height: 1 },
375
+ children: jsx('text', { style: { color: muted, dim: true }, children: `${displayPos.row + 1}/${lineMap.length}` }),
376
+ })
377
+ : null
378
+
368
379
  return jsx('box', {
369
- style: { flexDirection: 'column', height: displayHeight, minHeight: 1, flexGrow: 1 },
370
- children: rows,
380
+ style: { flexDirection: 'column', height: displayHeight + (counterActive ? 1 : 0), minHeight: 1, flexGrow: 1 },
381
+ children: counter ? [...rows, counter] : rows,
371
382
  })
372
383
  }