Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Workspace/WorkspaceView API changes #1

Closed
wants to merge 8 commits into from

Conversation

probablycorey
Copy link

This is a potential API for atom.workspace. The current methods for Workspace and WorkspaceView are combined to create a single more approachable API. Underused API methods are also removed or updated.

@kevinsawicki
Copy link

Could api.txt be api.md instead and be a big markdown table so it renders nicely?

@probablycorey
Copy link
Author

The text is aligned right now, would using markdown gives us more than that?

@kevinsawicki
Copy link

It would render in prose diff

::getActivePane() 85 51 2
::eachEditor(callback) 55 38 4
::registerOpener(opener) 41 40 10
::prependToBottom(element) 34 31 3
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the prependTo... and appendTo... methods we need to decide what type of object we want to pass in.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should refer to these objects as "panels". The contract for attaching them should be the same as for pane items, and I think we should support the following options:

  • A React component.
  • A plain JS object with a ::getDOMNode() method and some lifecycle hooks that we will call. That allows people to write adaptors to whatever framework they want.

Less recommended path for flexibility backward compatibility:

  • A SpacePen view / jQuery wrapper
  • A raw DOM element.

@probablycorey
Copy link
Author

I'll make a branch that uses markdown to see if the the diffs look better using prose diff.

@probablycorey
Copy link
Author

We can render it in markdown and view the diffs like this https://github.com/atom/api/compare/cj-markdown-diff...cj-markdown-diff-future?name=cj-markdown-diff-future&short_path=00e71df#diff-00e71df22262087fd8ad820708997657. I don't think it is any more readable, but if other people do I'll switch to it.

@kevinsawicki
Copy link

I was thinking a table would be nicer than a list, since there are columns

@benogle
Copy link
Contributor

benogle commented Jul 22, 2014

I think the txt format that's currently there is fine. There are already columns.

::focusPaneOnRight() 0 0 1
::prependToLeft(element) 0 0 0
::prependToRight(element) 0 0 0
::focusPaneAbove() 0 0 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be consistent about focus and activate and rename the focusPane... or activate..Pane methods.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go back to only exposing the view, focus could be a more recognizable concept. But the "active" pane is definitely different from the focused pane in that it's sticky. We record the most recently focused pane as active.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also get behind removing the focus and activate pane methods.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should they be methods on Pane probably so they're relative to some reference point? Or maybe just providing a standard way of getting the pane above/below/to-left/to-right and then you can do whatever you want with it.

@probablycorey
Copy link
Author

@nathansobo were there other changes you wanted to make to Workspace/WorkspaceView?

@@ -535,50 +535,30 @@ ThemeManager called packages a
::getUserStylesheetPath() 0 0 0
::requireStylesheet(stylesheetPath, type, htmlElement) 0 0 0

WorkspaceView called packages atom packages
::getActiveView() 96 61 8
::eachEditorView(callback) 89 79 10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the plan for each-ing?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After unifying view and model, it would be great to just support onEachEditor.

::unregisterOpener(opener) 3 3 1
::saveActivePaneItem() 2 2 0
::destroyActivePaneItem() 1 1 0
::destroyActivePane() 1 1 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced this with Pane::destroy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this one. These can just be methods on the actual pane / item.

@nathansobo
Copy link

I'd still like to work out how we query / subscribe to different kinds of "pane items". I'd also like to float the idea of renaming "pane items" to "editors" and referring to editors for text as "text editors". It's way less awkward terminology than "pane item" and a lot more specific than "view". The fact that some editors are read-only seems like an acceptable academic detail to me. I think the fact that avocode is already building an image editing system on top of this framework bolsters the idea that we shouldn't overly specialize on terminology that assumes text editing out of the gate.

activatePreviousPane is used by 3 packages, but it can be easily
fixed:

panes = atom.workspace.getPanes()
activePane = atom.workspace.getActivePane()
previousIndex = Math.max(0, panes.indexOf(activePane) - 1)
panes[previousIndex].activate()
@probablycorey probablycorey changed the title Workspace/WorkspaceView changes Workspace/WorkspaceView API changes Jul 22, 2014
This was referenced Jul 23, 2014
@probablycorey probablycorey deleted the cj-workspace-changes branch July 25, 2014 02:58
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants