mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 15:34:49 +01:00
chore: allow creating user deco from just name
This commit is contained in:
parent
117a540d6f
commit
74a5dc2ac0
1 changed files with 10 additions and 12 deletions
|
@ -10,7 +10,6 @@ class BufferMapper {
|
||||||
this.editorToBufferMapping.set(uri, buffer);
|
this.editorToBufferMapping.set(uri, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public uri_by_buffer(name: string): vscode.Uri | undefined {
|
public uri_by_buffer(name: string): vscode.Uri | undefined {
|
||||||
let uri = this.bufferToEditorMapping.get(name);
|
let uri = this.bufferToEditorMapping.get(name);
|
||||||
return uri;
|
return uri;
|
||||||
|
@ -39,27 +38,25 @@ export class UserDecoration {
|
||||||
decoration: vscode.TextEditorDecorationType | null;
|
decoration: vscode.TextEditorDecorationType | null;
|
||||||
color: string;
|
color: string;
|
||||||
buffer: string;
|
buffer: string;
|
||||||
startRow : number;
|
startRow : number
|
||||||
startCol : number;
|
startCol : number;
|
||||||
endRow : number;
|
endRow : number;
|
||||||
endCol : number;
|
endCol : number;
|
||||||
|
|
||||||
|
public constructor(name: string) {
|
||||||
public constructor(event: codemp.Cursor) {
|
let hash = codemp.hash(name);
|
||||||
let hash = codemp.hash(event.user || "anon");
|
|
||||||
this.color = colors[Math.abs(hash) % colors.length];
|
this.color = colors[Math.abs(hash) % colors.length];
|
||||||
this.decoration = null;
|
this.decoration = null;
|
||||||
this.buffer = event.buffer;
|
this.buffer = "";
|
||||||
this.startRow = event.startRow;
|
this.startRow = 0;
|
||||||
this.startCol = event.startCol;
|
this.startCol = 0;
|
||||||
this.endRow = event.endRow;
|
this.endRow = 0;
|
||||||
this.endCol = event.endCol;
|
this.endCol = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO can we avoid disposing and recreating the decoration type every time?
|
// TODO can we avoid disposing and recreating the decoration type every time?
|
||||||
public update(event: codemp.Cursor, editor?: vscode.TextEditor) {
|
public update(event: codemp.Cursor, editor?: vscode.TextEditor) {
|
||||||
this.buffer=event.buffer;
|
this.buffer = event.buffer;
|
||||||
this.startRow = event.startRow;
|
this.startRow = event.startRow;
|
||||||
this.startCol = event.startCol;
|
this.startCol = event.startCol;
|
||||||
this.endRow = event.endRow;
|
this.endRow = event.endRow;
|
||||||
|
@ -100,3 +97,4 @@ const colors = [
|
||||||
];
|
];
|
||||||
|
|
||||||
export const colors_cache: Map<string, UserDecoration> = new Map();
|
export const colors_cache: Map<string, UserDecoration> = new Map();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue