equal
deleted
inserted
replaced
1 'use strict'; |
1 'use strict'; |
2 |
2 |
3 import { TextDocumentContentProvider, ExtensionContext, Event, EventEmitter, Uri, Position, |
3 import { TextDocumentContentProvider, ExtensionContext, Event, EventEmitter, Uri, Position, |
4 ViewColumn, workspace, window, commands } from 'vscode' |
4 workspace, window, commands } from 'vscode' |
|
5 |
|
6 import * as library from './library' |
5 |
7 |
6 |
8 |
7 const uri_scheme = 'isabelle-preview'; |
9 const uri_scheme = 'isabelle-preview'; |
8 |
10 |
9 class Provider implements TextDocumentContentProvider |
11 class Provider implements TextDocumentContentProvider |
59 { |
61 { |
60 const [name] = <[string]>JSON.parse(preview_uri.query) |
62 const [name] = <[string]>JSON.parse(preview_uri.query) |
61 return Uri.parse(name) |
63 return Uri.parse(name) |
62 } |
64 } |
63 |
65 |
64 function other_column(): ViewColumn |
|
65 { |
|
66 const active = window.activeTextEditor |
|
67 if (!active || active.viewColumn === ViewColumn.Three) return ViewColumn.One |
|
68 else if (active.viewColumn === ViewColumn.One) return ViewColumn.Two |
|
69 else return ViewColumn.Three |
|
70 } |
|
71 |
|
72 export function init(context: ExtensionContext) |
66 export function init(context: ExtensionContext) |
73 { |
67 { |
74 const provider = new Provider() |
68 const provider = new Provider() |
75 context.subscriptions.push(workspace.registerTextDocumentContentProvider(uri_scheme, provider)) |
69 context.subscriptions.push(workspace.registerTextDocumentContentProvider(uri_scheme, provider)) |
76 context.subscriptions.push(provider) |
70 context.subscriptions.push(provider) |
78 context.subscriptions.push( |
72 context.subscriptions.push( |
79 commands.registerTextEditorCommand("isabelle.preview", editor => |
73 commands.registerTextEditorCommand("isabelle.preview", editor => |
80 { |
74 { |
81 const preview_uri = encode_name(editor.document.uri) |
75 const preview_uri = encode_name(editor.document.uri) |
82 return workspace.openTextDocument(preview_uri).then(doc => |
76 return workspace.openTextDocument(preview_uri).then(doc => |
83 commands.executeCommand("vscode.previewHtml", preview_uri, other_column(), "Isabelle Preview")) |
77 commands.executeCommand("vscode.previewHtml", preview_uri, |
|
78 library.other_column(), "Isabelle Preview")) |
84 })) |
79 })) |
85 |
80 |
86 context.subscriptions.push( |
81 context.subscriptions.push( |
87 workspace.onDidChangeTextDocument(event => |
82 workspace.onDidChangeTextDocument(event => |
88 { |
83 { |