Skip to content

Commit 004525a

Browse files
committed
feat: make position of output panel configurable
1 parent d2d127c commit 004525a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

lib/script-view.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export default class ScriptView extends MessagePanelView {
1818
this.scrollTimeout = null;
1919
this.ansiFilter = new AnsiFilter();
2020
this.headerView = headerView;
21+
this.position = this.parsePositionConfig(atom.config.get('script.position'));
22+
atom.config.observe('script.position', (newVal) => {
23+
this.position = this.parsePositionConfig(newVal);
24+
});
2125

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

34+
parsePositionConfig(value) {
35+
// Get the configured position of the view as one of the
36+
// valid values of the MessagePanelView.position parameter.
37+
let position;
38+
switch (value) {
39+
case 'Top':
40+
return 'top';
41+
case 'Bottom':
42+
return 'bottom';
43+
case 'Left':
44+
return 'left';
45+
case 'Right':
46+
return 'right';
47+
default:
48+
// Use bottom as the default, because that was the behaviour
49+
// before the position became configurable.
50+
return 'bottom';
51+
}
52+
}
53+
3054
addShowInTabIcon() {
3155
const icon = $$(function () {
3256
this.div({

lib/script.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ export const config = {
4949
'Directory of the script',
5050
],
5151
},
52+
position: {
53+
title: 'Panel position',
54+
description: 'Position of the panel with script output. '
55+
+ '(Changes to this value will be applied upon reopening the panel.)',
56+
type: 'string',
57+
default: 'Bottom',
58+
enum: [
59+
'Top',
60+
'Bottom',
61+
'Left',
62+
'Right',
63+
],
64+
},
5265
}
5366

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

0 commit comments

Comments
 (0)