2021-04-20 03:26:51 +02:00
|
|
|
export type Position = {
|
2021-09-05 01:09:30 +02:00
|
|
|
row: number;
|
|
|
|
column: number;
|
2021-04-20 03:26:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export class PositionTracker {
|
2021-09-05 01:09:30 +02:00
|
|
|
positions: Map<string, Position>;
|
2021-04-20 03:26:51 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
constructor() {
|
|
|
|
this.positions = new Map<string, Position>();
|
|
|
|
}
|
2021-04-20 03:26:51 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
saveCursor(filename: string, pos: Position): void {
|
|
|
|
this.positions.set(filename, pos);
|
|
|
|
}
|
2021-04-20 03:26:51 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
getCursor(filename: string): Position {
|
|
|
|
const position = this.positions.get(filename);
|
|
|
|
if (!position) {
|
|
|
|
return {
|
|
|
|
row: -1,
|
|
|
|
column: -1,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return position;
|
|
|
|
}
|
2021-04-30 05:52:56 +02:00
|
|
|
}
|
2021-04-20 03:26:51 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
export const CursorPositions: PositionTracker = new PositionTracker();
|