Skip to content

Commit

Permalink
Minor tweaks to gregjoy1's header position PR
Browse files Browse the repository at this point in the history
Closes #48
  • Loading branch information
dbkaplun committed Dec 22, 2014
1 parent 27dbbbc commit 1d45ac1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
33 changes: 11 additions & 22 deletions lib/ui/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,26 @@ function Header (opts) {

if (!(self instanceof blessed.Node)) return new Header(opts);

// Define the header options object
var headerOptions = _({
left: 0,
right: 0,
height: 1,
padding: {left: 1, right: 1},
})
var opts = _({
left: 0,
right: 0,
height: 1,
padding: {left: 1, right: 1},
})
.merge(Slap.global.options.header || {})
.merge({tags: true})
.merge(opts || {})
.toObject();

// If option headerPosition is not set, or is set to top; position header at the top.
if(headerOptions.headerPosition === undefined || headerOptions.headerPosition === 'top') {
// Variable headerPositon specifies which position the header is in.
self.headerPosition = 'top';
headerOptions.top = 0;
// Else if option headerPosition is set to bottom; position header at the bottom.
} else {
self.headerPosition = 'bottom';
headerOptions.bottom = 0;
}

BaseElement.call(self, headerOptions);
BaseElement.call(self, _(opts)
.merge(opts.headerPosition !== 'bottom'
? {top: 0, headerPosition: 'top'}
: {bottom: 0, headerPosition: 'bottom'})
.toObject());

var helpBinding = self.slap.options.bindings.help;
helpBinding = Array.isArray(helpBinding) ? helpBinding[0] : helpBinding;
self.helpButton = new Button(_({
parent: self,
content: "Help" + (helpBinding ? ": " + helpBinding : ""),
top: 0,
right: self.padding.right
})
.merge(self.options.helpButton || {})
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/Slap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function Slap (opts) {

self.fileBrowser = new FileBrowser({
parent: self,
top: self.header.headerPosition === 'top' ? 1 : 0,
bottom: self.header.headerPosition === 'bottom' ? 1 : 0,
top: self.header.options.headerPosition === 'top' ? 1 : 0,
bottom: self.header.options.headerPosition === 'bottom' ? 1 : 0,
left: 0,
});
self.fileBrowser.focus();
Expand Down
4 changes: 2 additions & 2 deletions slap.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[editor]
pageLines = 10
doubleClickDuration = 600
defaultEncoding = UTF-8
defaultEncoding = "UTF-8"

[editor.buffer]
useSpaces = true
Expand All @@ -21,7 +21,7 @@ lineNumberWidth = 4
[header]
messageDuration = 5000
blinkRate = 500
headerPosition = top
headerPosition = "top"

[fileBrowser]
width = 12
Expand Down

0 comments on commit 1d45ac1

Please sign in to comment.