Skip to content

Commit 40a3062

Browse files
committed
Add offset value to ParseToken
1 parent 99a10cd commit 40a3062

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ interface ParseToken {
2424
background: Color | null;
2525
// A Set of the applied decorations
2626
decorations: Set<DecorationType>;
27+
// Offset from the beginning of the input value
28+
offset: number;
2729
}
2830
```
2931

src/parser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ import { Color, namedColors } from './colors';
22
import { DecorationType, decorations } from './decorations';
33

44
export interface ParseToken {
5+
/** The text content of the token. */
56
value: string;
7+
/** The foreground color */
68
foreground: Color | null;
9+
/** The background color. */
710
background: Color | null;
11+
/** A Set of the applied decorations. */
812
decorations: Set<DecorationType>;
13+
/** Offset from the beginning of the input value. */
14+
offset: number;
915
}
1016

1117
function findSequence(value: string, position: number) {
@@ -172,6 +178,7 @@ export function createAnsiSequenceParser() {
172178
foreground,
173179
background,
174180
decorations: new Set(decorations),
181+
offset: position,
175182
});
176183
}
177184

0 commit comments

Comments
 (0)