20 export function get_color(color: string, light: boolean): string |
20 export function get_color(color: string, light: boolean): string |
21 { |
21 { |
22 const config = color + (light ? "_light" : "_dark") + "_color" |
22 const config = color + (light ? "_light" : "_dark") + "_color" |
23 return get_configuration<string>(config) |
23 return get_configuration<string>(config) |
24 } |
24 } |
|
25 |
|
26 |
|
27 /* caret handling and dynamic output */ |
|
28 |
|
29 interface Caret_Update |
|
30 { |
|
31 uri?: string |
|
32 line?: number |
|
33 character?: number |
|
34 } |
|
35 |
|
36 const caret_update_type = new NotificationType<Caret_Update, void>("PIDE/caret_update") |
|
37 const dynamic_output_type = new NotificationType<string, void>("PIDE/dynamic_output") |
|
38 |
|
39 let last_caret_update: Caret_Update = {} |
|
40 let dynamic_output: string = "" |
|
41 |
25 |
42 |
26 |
43 |
27 /* activate extension */ |
44 /* activate extension */ |
28 |
45 |
29 export function activate(context: vscode.ExtensionContext) |
46 export function activate(context: vscode.ExtensionContext) |
56 }; |
73 }; |
57 |
74 |
58 const client = new LanguageClient("Isabelle", server_options, client_options, false) |
75 const client = new LanguageClient("Isabelle", server_options, client_options, false) |
59 |
76 |
60 |
77 |
|
78 /* caret handling and dynamic output */ |
|
79 |
|
80 function update_caret() |
|
81 { |
|
82 const editor = vscode.window.activeTextEditor |
|
83 let caret_update: Caret_Update = {} |
|
84 if (editor) { |
|
85 const uri = editor.document.uri |
|
86 const cursor = editor.selection.active |
|
87 if (uri.scheme === "file" && cursor) |
|
88 caret_update = { uri: uri.toString(), line: cursor.line, character: cursor.character } |
|
89 } |
|
90 if (last_caret_update !== caret_update) { |
|
91 client.sendNotification(caret_update_type, caret_update) |
|
92 last_caret_update = caret_update |
|
93 } |
|
94 } |
|
95 |
|
96 client.onReady().then(() => |
|
97 { |
|
98 client.onNotification(dynamic_output_type, body => { dynamic_output = body }) |
|
99 vscode.window.onDidChangeActiveTextEditor(_ => update_caret()) |
|
100 vscode.window.onDidChangeTextEditorSelection(_ => update_caret()) |
|
101 update_caret() |
|
102 }) |
|
103 |
|
104 |
61 /* decorations */ |
105 /* decorations */ |
62 |
106 |
63 decorations.init(context) |
107 decorations.init(context) |
64 vscode.workspace.onDidChangeConfiguration(() => decorations.init(context)) |
108 vscode.workspace.onDidChangeConfiguration(() => decorations.init(context)) |
65 vscode.window.onDidChangeActiveTextEditor(decorations.update_editor) |
109 vscode.window.onDidChangeActiveTextEditor(decorations.update_editor) |