linecraft 0.5.3 → 0.5.5
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/README.md +41 -7
- package/lib/components/code-debug.d.ts +2 -0
- package/lib/components/code-debug.d.ts.map +1 -1
- package/lib/components/code-debug.js +224 -255
- package/lib/components/code-debug.js.map +1 -1
- package/lib/components/code-debug.test.d.ts +2 -0
- package/lib/components/code-debug.test.d.ts.map +1 -0
- package/lib/components/code-debug.test.js +253 -0
- package/lib/components/code-debug.test.js.map +1 -0
- package/lib/components/styled.d.ts +1 -0
- package/lib/components/styled.d.ts.map +1 -1
- package/lib/components/styled.js +36 -7
- package/lib/components/styled.js.map +1 -1
- package/lib/layout/grid.d.ts +3 -2
- package/lib/layout/grid.d.ts.map +1 -1
- package/lib/layout/grid.js +93 -45
- package/lib/layout/grid.js.map +1 -1
- package/lib/layout/grid.test.js +67 -0
- package/lib/layout/grid.test.js.map +1 -1
- package/lib/native/diff.test.js.map +1 -1
- package/lib/native/region-renderer.d.ts +1 -0
- package/lib/native/region-renderer.d.ts.map +1 -1
- package/lib/native/region-renderer.js +31 -1
- package/lib/native/region-renderer.js.map +1 -1
- package/lib/region.d.ts.map +1 -1
- package/lib/region.js +0 -46
- package/lib/region.js.map +1 -1
- package/lib/utils/cursor-position.d.ts.map +1 -1
- package/lib/utils/cursor-position.js +4 -13
- package/lib/utils/cursor-position.js.map +1 -1
- package/lib/utils/text.d.ts +64 -2
- package/lib/utils/text.d.ts.map +1 -1
- package/lib/utils/text.js +670 -102
- package/lib/utils/text.js.map +1 -1
- package/lib/utils/text.test.d.ts +2 -0
- package/lib/utils/text.test.d.ts.map +1 -0
- package/lib/utils/text.test.js +237 -0
- package/lib/utils/text.test.js.map +1 -0
- package/lib/utils/wait-for-spacebar.d.ts.map +1 -1
- package/lib/utils/wait-for-spacebar.js +0 -7
- package/lib/utils/wait-for-spacebar.js.map +1 -1
- package/package.json +1 -1
package/lib/utils/text.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare function stripAnsi(text: string): string;
|
|
|
15
15
|
* Truncate text to a maximum visual width while preserving ANSI escape codes
|
|
16
16
|
*
|
|
17
17
|
* This function truncates text based on its visual width (ignoring ANSI codes),
|
|
18
|
-
* but preserves all ANSI escape sequences in the output.
|
|
19
|
-
*
|
|
18
|
+
* but preserves all ANSI escape sequences in the output. Active ANSI codes are
|
|
19
|
+
* preserved in the truncated result.
|
|
20
20
|
*
|
|
21
21
|
* @param text - Text that may contain ANSI escape codes
|
|
22
22
|
* @param maxWidth - Maximum visual width (number of visible characters)
|
|
@@ -29,6 +29,9 @@ export declare function truncateToWidth(text: string, maxWidth: number): string;
|
|
|
29
29
|
/**
|
|
30
30
|
* Truncate text with ellipsis at the end, preserving ANSI escape codes
|
|
31
31
|
*
|
|
32
|
+
* Active ANSI codes from the truncated portion are preserved, and the ellipsis
|
|
33
|
+
* is added after the truncated text (without ANSI codes).
|
|
34
|
+
*
|
|
32
35
|
* @param text - Text that may contain ANSI escape codes
|
|
33
36
|
* @param maxWidth - Maximum visual width (number of visible characters)
|
|
34
37
|
* @returns Truncated text with '...' at the end, ANSI codes preserved
|
|
@@ -40,6 +43,10 @@ export declare function truncateEnd(text: string, maxWidth: number): string;
|
|
|
40
43
|
/**
|
|
41
44
|
* Truncate text with ellipsis at the beginning, preserving ANSI escape codes
|
|
42
45
|
*
|
|
46
|
+
* When truncating from the start, we preserve ANSI codes that are active in the
|
|
47
|
+
* remaining portion. The ellipsis is added at the beginning (without ANSI codes),
|
|
48
|
+
* and active codes from the original text are re-applied to the remaining portion.
|
|
49
|
+
*
|
|
43
50
|
* @param text - Text that may contain ANSI escape codes
|
|
44
51
|
* @param maxWidth - Maximum visual width (number of visible characters)
|
|
45
52
|
* @returns Truncated text with '...' at the beginning, ANSI codes preserved
|
|
@@ -51,6 +58,9 @@ export declare function truncateStart(text: string, maxWidth: number): string;
|
|
|
51
58
|
/**
|
|
52
59
|
* Truncate text with ellipsis in the middle, preserving ANSI escape codes
|
|
53
60
|
*
|
|
61
|
+
* When truncating in the middle, we preserve ANSI codes from the start portion
|
|
62
|
+
* and re-apply them to the end portion to maintain consistent styling.
|
|
63
|
+
*
|
|
54
64
|
* @param text - Text that may contain ANSI escape codes
|
|
55
65
|
* @param maxWidth - Maximum visual width (number of visible characters)
|
|
56
66
|
* @returns Truncated text with '...' in the middle, ANSI codes preserved
|
|
@@ -59,8 +69,60 @@ export declare function truncateStart(text: string, maxWidth: number): string;
|
|
|
59
69
|
* truncateMiddle('\x1b[31mHello World\x1b[0m', 8) // '\x1b[31mHel...ld\x1b[0m'
|
|
60
70
|
*/
|
|
61
71
|
export declare function truncateMiddle(text: string, maxWidth: number): string;
|
|
72
|
+
/**
|
|
73
|
+
* Map an original column position to its display position in truncated text
|
|
74
|
+
*
|
|
75
|
+
* This function takes the original text, the truncated result, and the visible range
|
|
76
|
+
* that was shown, and maps an original column to where it appears in the truncated text.
|
|
77
|
+
*
|
|
78
|
+
* @param originalText - The original text (plain, no ANSI)
|
|
79
|
+
* @param truncatedText - The truncated text result (may have ellipsis)
|
|
80
|
+
* @param visibleStartCol - The first column that was shown (1-based, includes truncated before)
|
|
81
|
+
* @param visibleEndCol - The last column that was shown (1-based, includes truncated after)
|
|
82
|
+
* @param originalCol - The original column to map (1-based)
|
|
83
|
+
* @param rangeStartCol - The start column of the main range (1-based, optional, for better accuracy)
|
|
84
|
+
* @param rangeEndCol - The end column of the main range (1-based, optional, for better accuracy)
|
|
85
|
+
* @returns The display position in the truncated text (1-based, visible characters)
|
|
86
|
+
*/
|
|
87
|
+
export declare function mapColumnToDisplay(originalText: string, truncatedText: string, visibleStartCol: number, visibleEndCol: number, originalCol: number, rangeStartCol?: number, rangeEndCol?: number): number;
|
|
88
|
+
/**
|
|
89
|
+
* Result of truncateFocusRange, including information about what range was shown
|
|
90
|
+
*/
|
|
91
|
+
export interface TruncateFocusRangeResult {
|
|
92
|
+
/** The truncated text with target range visible */
|
|
93
|
+
text: string;
|
|
94
|
+
/** The first column that was shown (1-based, includes truncated before portion) */
|
|
95
|
+
visibleStartCol: number;
|
|
96
|
+
/** The last column that was shown (1-based, includes truncated after portion) */
|
|
97
|
+
visibleEndCol: number;
|
|
98
|
+
/** The start column of the main range (1-based, the focused portion) */
|
|
99
|
+
rangeStartCol: number;
|
|
100
|
+
/** The end column of the main range (1-based, the focused portion) */
|
|
101
|
+
rangeEndCol: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Truncate text to show a specific column range, with ellipsis as needed
|
|
105
|
+
*
|
|
106
|
+
* This function ensures a target range (startCol to endCol) is visible in the output,
|
|
107
|
+
* adding ellipsis at the start, end, or both as needed to fit within maxWidth.
|
|
108
|
+
* All ANSI codes and OSC 8 hyperlinks are preserved.
|
|
109
|
+
*
|
|
110
|
+
* @param text - Text that may contain ANSI escape codes
|
|
111
|
+
* @param maxWidth - Maximum visual width (number of visible characters)
|
|
112
|
+
* @param targetStartCol - Start column of target range (1-based)
|
|
113
|
+
* @param targetEndCol - End column of target range (1-based, optional)
|
|
114
|
+
* @param maxColumn - Maximum column to show (optional, for limiting display)
|
|
115
|
+
* @returns Truncated text with target range visible, ANSI codes preserved, and visible range info
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* truncateFocusRange('console.log("hello world");', 20, 1, 11)
|
|
119
|
+
* // Returns text showing columns 1-11 with ellipsis if needed
|
|
120
|
+
*/
|
|
121
|
+
export declare function truncateFocusRange(text: string, maxWidth: number, targetStartCol: number, targetEndCol?: number, maxColumn?: number): TruncateFocusRangeResult;
|
|
62
122
|
/**
|
|
63
123
|
* Wrap text to fit within a width, breaking on spaces
|
|
124
|
+
* Never breaks words mid-word - if a word is too long, it will extend the line
|
|
125
|
+
* ANSI-aware: calculates width based on visible characters, not raw string length
|
|
64
126
|
*/
|
|
65
127
|
export declare function wrapText(text: string, width: number): string[];
|
|
66
128
|
/**
|
package/lib/utils/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB9C;AAwDD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgCtE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuBlE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CA8BpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsCrE;AAqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CA+DR;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,eAAe,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;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