Skip to content

Commit ccfaa71

Browse files
committed
views.activate
1 parent 5c4a98d commit ccfaa71

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/ui.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports =
3131
@subs.dispose()
3232

3333
consumeInk: (@ink) ->
34-
@views.ink = @ink
34+
@views.activate(@ink)
3535
@selector.activate(@ink)
3636
@docpane.activate(@ink)
3737
@progress.activate(@ink)

lib/ui/views.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { once } from '../misc';
55

66
const getlazy = client.import('getlazy');
77

8+
let ink;
9+
export function activate (ink_in) {
10+
ink = ink_in
11+
}
812

913
export function dom({tag, attrs, contents}, opts) {
1014
const view = document.createElement(tag);
@@ -37,7 +41,7 @@ export function html(...args) {
3741
}
3842

3943
export function tree({head, children, expand}, opts) {
40-
this.ink.tree.treeView(render(head, opts),
44+
ink.tree.treeView(render(head, opts),
4145
children.map(x=> render(tags.div([x]), opts)),
4246
{expand});
4347
}
@@ -50,13 +54,13 @@ export function lazy({head, id}, opts) {
5054
console.warn('Unregistered lazy view');
5155
}
5256
let view;
53-
return view = this.ink.tree.treeView(render(head, opts), [], {
57+
return view = ink.tree.treeView(render(head, opts), [], {
5458
onToggle: once(() => {
5559
if (client.conn !== conn) { return; }
5660
getlazy(id).then(children => {
5761
const body = view.querySelector(':scope > .body');
5862
children.map(x => render(tags.div([x]), opts)).forEach(x => {
59-
body.appendChild(this.ink.ansiToHTML(x));
63+
body.appendChild(ink.ansiToHTML(x));
6064
});
6165
});
6266
})
@@ -92,13 +96,13 @@ export function link({file, line, contents}) {
9296
// TODO: maybe need to dispose of the tooltip onclick and readd them, but
9397
// that doesn't seem to be necessary
9498
let tt;
95-
if (this.ink.Opener.isUntitled(file)) {
99+
if (ink.Opener.isUntitled(file)) {
96100
tt = atom.tooltips.add(view, {title() { return 'untitled'; }});
97101
} else {
98102
tt = atom.tooltips.add(view, {title() { return file; }});
99103
}
100104
view.onclick = e => {
101-
this.ink.Opener.open(file, line, {
105+
ink.Opener.open(file, line, {
102106
pending: atom.config.get('core.allowPendingPaneItems')
103107
});
104108
e.stopPropagation();
@@ -131,7 +135,7 @@ export function code({text, attrs, scope}) {
131135

132136
export function latex({attrs, text}) {
133137
const block = (attrs != null ? attrs.block : undefined) || false; // attrs?.block || false
134-
const latex = this.ink.KaTeX.texify(text, block);
138+
const latex = ink.KaTeX.texify(text, block);
135139
return render({type: 'html', block, content: latex});
136140
}
137141

@@ -152,7 +156,7 @@ export const views = {
152156
export function render(data, opts = {}) {
153157
if (views.hasOwnProperty(data.type)) {
154158
const r = views[data.type](data, opts);
155-
this.ink.ansiToHTML(r);
159+
ink.ansiToHTML(r);
156160
return r;
157161
} else if ((data != null ? data.constructor : undefined) === String) { // data?.constructor === String
158162
return new Text(data);

0 commit comments

Comments
 (0)