Skip to content

Commit

Permalink
Added numbers to different panels in 'open files' panes
Browse files Browse the repository at this point in the history
  • Loading branch information
oriolmirosa committed Jun 8, 2017
1 parent c361c20 commit e916366
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.0

- When several panels are open, the title for the 'open files' panels now includes PANEL #, with the number showing the order in which the panels were opened. When panels are closed, the numbers of the panels are re-calculated so that they reflect the panels present in the workspace

## 0.6.2

- Fixed a bug that threw an error whenever a new file was created after closing the 'Settings' page (mentioned in [#17](https://github.com/oriolmirosa/open-files/issues/17)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ This package is basically a fork of the [tree-view-open-files](https://atom.io/p
* The cross to close a file only appears when the mouse hovers over the entry (while the 'edited' marker is always visible).
* NEW in 0.6.0: In order to prevent the fast sliding down of the tree view when a file is added, there is a delay before the file appears in the 'open files' panel. The delay is configurable in the package's settings (default is 1000 ms, i.e., 1 second).
* NEW in 0.6.0: Files added and removed from the 'open files' panel are animated. The animation has a default duration of 300 ms, but this is configurable in the package's settings (default is 300 ms).
* NEW in 0.7.0: When several panels are open, the title for the 'open files' panels now includes PANEL #, with the number showing the order in which the panels were opened. When panels are closed, the numbers of the panels are re-calculated so that they reflect the panels present in the workspace

## TODO

* Right now, when there are several panes in the editor, each one has its own 'open files' section in the tree-view, but they are all labeled 'open files'. The goal is for them to have a more descriptive label.
* Make the files in the 'open files' panel draggable, and keep the tab order in sync with the 'open files' order.
* Configuration. Ideas and suggestions for further configuration options are welcome.
1 change: 1 addition & 0 deletions lib/open-files-pane-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class OpenFilesPaneView {
this.container = document.createElement('ol')
this.container.classList.add('list-tree')
let header = document.createElement('div')
header.classList.add('open-files-title')

atom.config.observe('open-files.collapsable', collapsable => {
if (collapsable) {
Expand Down
25 changes: 22 additions & 3 deletions lib/open-files-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ export default class OpenFilesView {
this.addTabGroup(pane)
let destroySub = pane.onDidDestroy(() => {
destroySub.dispose()
return this.removeTabGroup(pane)
this.removeTabGroup(pane)
setTimeout(() => {
if (atom.workspace.getCenter().getPanes().length === 1) {
let title = document.querySelector('.open-files-title')
title.innerHTML = '<span><strong>OPEN FILES</strong></span>'
} else if (atom.workspace.getCenter().getPanes().length > 1) {
let titles = document.querySelectorAll('.open-files-title')
for (let i = 0; i < titles.length; i++) {
titles[i].innerHTML = '<span><strong>PANEL #' + (i + 1) + ' - OPEN FILES</strong></span>'
}
}
})
})
return this.paneSub.add(destroySub)
}))
Expand All @@ -68,13 +79,21 @@ export default class OpenFilesView {
let group = new OpenFilesPaneView
group.setPane(pane, this.addIconToElement)
this.groups.push(group)
return this.element.appendChild(group.element)
this.element.appendChild(group.element)
if (this.groups.length > 1) {
setTimeout(() => {
let titles = document.querySelectorAll('.open-files-title')
for (let i = 0; i < titles.length; i++) {
titles[i].innerHTML = '<span><strong>PANEL #' + (i + 1) + ' - OPEN FILES</strong></span>'
}
})
}
}

removeTabGroup(pane) {
let group = _.findIndex(this.groups, group => group.pane === pane)
this.groups[group].destroy()
return this.groups.splice(group, 1)
this.groups.splice(group, 1)
}
// Returns an object that can be retrieved when package is activated
serialize() {}
Expand Down

0 comments on commit e916366

Please sign in to comment.