mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 07:24:49 +01:00
New Class for BufferMappings
This commit is contained in:
parent
fa6a0b2399
commit
03eda74d78
1 changed files with 40 additions and 0 deletions
40
src/mapping.ts
Normal file
40
src/mapping.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import * as vscode from 'vscode';
|
||||
import * as codemp from '../index'; // TODO why won't it work with a custom name???
|
||||
|
||||
export class BufferMapping {
|
||||
buffer: codemp.JsBufferController;
|
||||
editor: vscode.TextEditor;
|
||||
|
||||
constructor(codemp_buffer: codemp.JsBufferController, editor: vscode.TextEditor) {
|
||||
this.buffer = codemp_buffer;
|
||||
this.editor = editor;
|
||||
}
|
||||
}
|
||||
|
||||
export class BufferMappingContainer {
|
||||
store: BufferMapping[];
|
||||
|
||||
constructor() {
|
||||
this.store = [];
|
||||
}
|
||||
|
||||
put(mapping: BufferMapping) {
|
||||
this.store.push(mapping);
|
||||
}
|
||||
|
||||
get_by_editor(uri: vscode.Uri) : BufferMapping | null {
|
||||
for (let mapping of this.store) {
|
||||
if (mapping.editor.document.uri === uri)
|
||||
return mapping;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
get_by_buffer(path: string) : BufferMapping | null {
|
||||
for (let mapping of this.store) {
|
||||
if (mapping.buffer.getName() === path)
|
||||
return mapping;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue