Skip to content

Commit

Permalink
feat: make position of output panel configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Singond committed Mar 21, 2021
1 parent d2d127c commit 004525a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/script-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default class ScriptView extends MessagePanelView {
this.scrollTimeout = null;
this.ansiFilter = new AnsiFilter();
this.headerView = headerView;
this.position = this.parsePositionConfig(atom.config.get('script.position'));
atom.config.observe('script.position', (newVal) => {
this.position = this.parsePositionConfig(newVal);
});

this.showInTab = this.showInTab.bind(this);
this.setHeaderAndShowExecutionTime = this.setHeaderAndShowExecutionTime.bind(this);
Expand All @@ -27,6 +31,26 @@ export default class ScriptView extends MessagePanelView {
linkPaths.listen(this.body);
}

parsePositionConfig(value) {
// Get the configured position of the view as one of the
// valid values of the MessagePanelView.position parameter.
let position;
switch (value) {
case 'Top':
return 'top';
case 'Bottom':
return 'bottom';
case 'Left':
return 'left';
case 'Right':
return 'right';
default:
// Use bottom as the default, because that was the behaviour
// before the position became configurable.
return 'bottom';
}
}

addShowInTabIcon() {
const icon = $$(function () {
this.div({
Expand Down
13 changes: 13 additions & 0 deletions lib/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ export const config = {
'Directory of the script',
],
},
position: {
title: 'Panel position',
description: 'Position of the panel with script output. '
+ '(Changes to this value will be applied upon reopening the panel.)',
type: 'string',
default: 'Bottom',
enum: [
'Top',
'Bottom',
'Left',
'Right',
],
},
}

// For some reason, the text of these options does not show in package settings view
Expand Down

0 comments on commit 004525a

Please sign in to comment.