@@ -2,10 +2,16 @@ import { Color, namedColors } from './colors';
2
2
import { DecorationType , decorations } from './decorations' ;
3
3
4
4
export interface ParseToken {
5
+ /** The text content of the token. */
5
6
value : string ;
7
+ /** The foreground color */
6
8
foreground : Color | null ;
9
+ /** The background color. */
7
10
background : Color | null ;
11
+ /** A Set of the applied decorations. */
8
12
decorations : Set < DecorationType > ;
13
+ /** Offset from the beginning of the input value. */
14
+ offset : number ;
9
15
}
10
16
11
17
function findSequence ( value : string , position : number ) {
@@ -153,6 +159,7 @@ export function createAnsiSequenceParser() {
153
159
let foreground : Color | null = null ;
154
160
let background : Color | null = null ;
155
161
let decorations : Set < DecorationType > = new Set ( ) ;
162
+ let chunkOffset = 0 ;
156
163
157
164
return {
158
165
parse ( value : string ) {
@@ -172,6 +179,7 @@ export function createAnsiSequenceParser() {
172
179
foreground,
173
180
background,
174
181
decorations : new Set ( decorations ) ,
182
+ offset : chunkOffset + position
175
183
} ) ;
176
184
}
177
185
@@ -208,6 +216,8 @@ export function createAnsiSequenceParser() {
208
216
position = findResult . position ;
209
217
} while ( position < value . length ) ;
210
218
219
+ chunkOffset += value . length ;
220
+
211
221
return tokens ;
212
222
} ,
213
223
} ;
0 commit comments