Skip to content

Commit

Permalink
views.activate
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 12, 2020
1 parent 45b50e4 commit f5e9e0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/ui.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports =
@subs.dispose()

consumeInk: (@ink) ->
@views.ink = @ink
@views.activate(@ink)
@selector.activate(@ink)
@docpane.activate(@ink)
@progress.activate(@ink)
Expand Down
19 changes: 11 additions & 8 deletions lib/ui/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { once } from '../misc';

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

// TODO this.ink is not imported!
let ink;
export function activate (ink_in) {
ink = ink_in
}

export function dom({tag, attrs, contents}, opts) {
const view = document.createElement(tag);
Expand Down Expand Up @@ -38,7 +41,7 @@ export function html(...args) {
}

export function tree({head, children, expand}, opts) {
this.ink.tree.treeView(render(head, opts),
ink.tree.treeView(render(head, opts),
children.map(x=> render(tags.div([x]), opts)),
{expand});
}
Expand All @@ -51,13 +54,13 @@ export function lazy({head, id}, opts) {
console.warn('Unregistered lazy view');
}
let view;
return view = this.ink.tree.treeView(render(head, opts), [], {
return view = ink.tree.treeView(render(head, opts), [], {
onToggle: once(() => {
if (client.conn !== conn) { return; }
getlazy(id).then(children => {
const body = view.querySelector(':scope > .body');
children.map(x => render(tags.div([x]), opts)).forEach(x => {
body.appendChild(this.ink.ansiToHTML(x));
body.appendChild(ink.ansiToHTML(x));
});
});
})
Expand Down Expand Up @@ -93,13 +96,13 @@ export function link({file, line, contents}) {
// TODO: maybe need to dispose of the tooltip onclick and readd them, but
// that doesn't seem to be necessary
let tt;
if (this.ink.Opener.isUntitled(file)) {
if (ink.Opener.isUntitled(file)) {
tt = atom.tooltips.add(view, {title() { return 'untitled'; }});
} else {
tt = atom.tooltips.add(view, {title() { return file; }});
}
view.onclick = e => {
this.ink.Opener.open(file, line, {
ink.Opener.open(file, line, {
pending: atom.config.get('core.allowPendingPaneItems')
});
e.stopPropagation();
Expand Down Expand Up @@ -132,7 +135,7 @@ export function code({text, attrs, scope}) {

export function latex({attrs, text}) {
const block = (attrs != null ? attrs.block : undefined) || false; // attrs?.block || false
const latex = this.ink.KaTeX.texify(text, block);
const latex = ink.KaTeX.texify(text, block);
return render({type: 'html', block, content: latex});
}

Expand All @@ -153,7 +156,7 @@ export const views = {
export function render(data, opts = {}) {
if (views.hasOwnProperty(data.type)) {
const r = views[data.type](data, opts);
this.ink.ansiToHTML(r);
ink.ansiToHTML(r);
return r;
} else if ((data != null ? data.constructor : undefined) === String) { // data?.constructor === String
return new Text(data);
Expand Down

0 comments on commit f5e9e0e

Please sign in to comment.