bitburner-src/src/ScriptEditor/CursorPositions.ts

30 lines
569 B
TypeScript
Raw Normal View History

interface Position {
2021-09-05 01:09:30 +02:00
row: number;
column: number;
}
2021-09-22 02:30:00 +02:00
class PositionTracker {
2021-09-05 01:09:30 +02:00
positions: Map<string, Position>;
2021-09-05 01:09:30 +02:00
constructor() {
this.positions = new Map<string, Position>();
}
2021-09-05 01:09:30 +02:00
saveCursor(filename: string, pos: Position): void {
this.positions.set(filename, pos);
}
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-09-05 01:09:30 +02:00
export const CursorPositions: PositionTracker = new PositionTracker();