Skip to content

Commit

Permalink
Merge pull request #71 from boltex:boltex/issue30
Browse files Browse the repository at this point in the history
Many new features for issues #16, #30, #25  and #43. NEEDS TESTING AND REVIEW
  • Loading branch information
boltex committed Jul 8, 2020
2 parents 6f1f549 + 94f457f commit b520073
Show file tree
Hide file tree
Showing 24 changed files with 987 additions and 228 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 0.1.13

- Added support for precise focus placement, focus switch between tree/body.
- Made the extension more aware of the current selection state, to have strictly relevant buttons visible shown only.
- Made the 'edit headline' hover icon removable, in order to enable 'Tab' keybinding to go from tree to body directly.
- Added commands and keybindings for 'goto' operations 'hoist/dehoist' [#25](https://github.com/boltex/leointeg/issues/25) and other commands. [#30](https://github.com/boltex/leointeg/issues/30)
- Added support for Leo-Style outline navigation. [#43](https://github.com/boltex/leointeg/issues/43) Has to be enabled with an option in the config settings: "Use Leo Tree Browsing" which makes arrow keys move selection instead of a cursor when focus is on the tree outline.

## 0.1.12

- Added support for multiple opened files along with the 'new', 'Close', 'Save-As' commands.
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ If you're having problems with the procedures below, try [running this sample ex

## Development requirements

- **use Leo's 'devel' branch** (This is temporary until Leo's next release)

- Make sure you have [Node.js](https://nodejs.org/en/download/) and [Git](https://git-scm.com/downloads) installed.

- Check your node.js version by typing `node -v` in a terminal. [The latest lts version is 12.18.0](https://nodejs.org/en/download/).
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ or on [github](https://github.com/leo-editor/leo-editor), and vscode at [code.vi

## Development version installation

In addition to the above requirements, make sure you have Node.js and Git installed, then clone the sources and run `npm install` in a terminal to install the remaining development dependencies.
In addition to the above requirements, **use Leo's 'devel' branch** (This is temporary until Leo's next release), make sure you have Node.js and Git installed, then clone the sources and run `npm install` in a terminal to install the remaining development dependencies.

![run extension](/resources/run-extension.png)

Expand All @@ -32,6 +32,7 @@ You can then run the **Run Extension** target, as shown above, in the **Debug Vi
## Features

- UI controls such as a **Leo Outline** in the explorer view, or as a standalone sidebar, **body panes**, **opened documents selector** and **Log Window**.
- Keybindings that match those from Leo, and a **'Leo Tree Browsing'** switch that enables Leo-style arrow keys behavior, for outline keyboard navigation.
- A **welcome screen** that also gives access to this extension's **settings**.
- **Derived files change detection**. See [External Files](#derive-external-files) below for more details
- Access **Leo commands** with context menus, outline-node hover icons, keyboard shortcuts, or the command palette:
Expand All @@ -46,7 +47,7 @@ You can then run the **Run Extension** target, as shown above, in the **Debug Vi

> _More commands are available by opening the **Command Palette** and typing 'Leo'_
| Keybinding | | | Command |
| Commands Keybinding | | | Command |
| :------------------------- | :-- | :-------------------- | :----------------- |
| `Alt + -` | | | Contract All |
| `Ctrl + I` | | | Insert Node |
Expand All @@ -59,11 +60,23 @@ You can then run the **Run Extension** target, as shown above, in the **Debug Vi
| `Ctrl + B` | | | Execute Script |
| `Ctrl + M` | | | Mark / Unmark |
| `Ctrl + {` | | `Ctrl + }` | Promote / Demote |
| `Alt + A` | | | Sort Siblings |
| `Ctrl + U` | or | `Shift + Alt + Up` | Move Outline Up |
| `Ctrl + D` | or | `Shift + Alt + Down` | Move Outline Down |
| `Ctrl + L` | or | `Shift + Alt + Left` | Move Outline Left |
| `Ctrl + R` | or | `Shift + Alt + Right` | Move Outline Right |

### Tree Browsing Keybindings

| Tree Browsing Keybinding | | With **'Leo Tree Browsing'** enabled | Command |
| :----------------------- | :-- | :----------------------------------- | :----------------------- |
| `Alt + Home` | | | Go To First Visible Node |
| `Alt + End` | | | Go To Last Sibling |
| `Alt + N` | | | Go To Next Clone |
| `Alt + Arrow Keys` | or | `Arrow Keys` | Browse Tree |
| `Ctrl + T` | | | Switch Tree/Body Focus |
| `Tab` | | | Focus from Tree to Body |

## Derive External Files

Use the **Save Leo File** command to derive external files.
Expand Down Expand Up @@ -110,14 +123,15 @@ Main issues are listed below. See the repository's [Issues Page](https://github.
If you're experiencing trouble with the keyboard shortcuts for
the 'Clone Node' or the 'Promote' and 'Demote' commands,
use **"keyboard.dispatch": "keyCode"** in your settings and restart vscode.
See [Troubleshoot Linux Keybindings](https://github.com/microsoft/vscode/wiki/Keybinding-Issues#troubleshoot-linux-keybindings) for more information.
See [Troubleshoot Linux Keybindings](https://github.com/microsoft/vscode/wiki/Keybinding-Issues#troubleshoot-linux-keybindings)
for more information.

### Move outline keyboard commands

For some users, the **`Ctrl+D`** keybinding is already assigned.
To help with this conflict, outline-move keyboard commands will only trigger
For some users, the **`Alt+[Arrow Keys]`**, **`Ctrl+D`** and **`Ctrl+T`** keybinding are already assigned.
To help with this conflict, tree-browsing, outline-move keyboard commands, and switch focus command will only trigger
with the additional condition of having no text selection in the editor.
So select at least one character to use the previously assigned **`Ctrl+D`** command in body panes.
So select at least one character to use the previously assigned original keyboard commands while focus is in the body pane.

> This extension is still in development, so please refer to its [issue tracker](https://github.com/boltex/leointeg/issues) to learn more about its intended features, or to contribute with additional information if you encounter other issues yourself.
Expand All @@ -134,6 +148,7 @@ The outline pane is made by implementing a [TreeDataProvider for vscode's TreeVi
- [Edward K. Ream](https://github.com/edreamleo) creator of the [Leo Editor](https://leoeditor.com/)
- [Eric Amodio](https://github.com/eamodio) for the [welcome screen templates](https://github.com/eamodio/vscode-gitlens/tree/master/src/webviews)
- [Vitalije](https://github.com/vitalije) for his contributions and support
- [Arjan](https://github.com/ar-jan) for his suggestions and ideas

---

Expand Down
72 changes: 68 additions & 4 deletions leoInteg.leo
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@
<v t="felix.20191126232434.10"><vh>outputPNode</vh></v>
<v t="felix.20191126232434.11"><vh>outputPNodes</vh></v>
</v>
<v t="felix.20200705193918.1"><vh>Outline Goto Commands</vh>
<v t="felix.20200705193927.1"><vh>gotoFirstVisible</vh></v>
<v t="felix.20200705233325.1"><vh>gotoLastVisible</vh></v>
<v t="felix.20200705201100.1"><vh>gotoLastSibling</vh></v>
<v t="felix.20200705223536.1"><vh>gotoNextVisible</vh></v>
<v t="felix.20200705223541.1"><vh>gotoPrevVisible</vh></v>
<v t="felix.20200706030410.1"><vh>gotoNextMarked</vh></v>
<v t="felix.20200706202247.1"><vh>gotoNextClone</vh></v>
<v t="felix.20200705223430.1"><vh>contractOrGoLeft</vh></v>
<v t="felix.20200705223521.1"><vh>expandAndGoRight</vh></v>
</v>
<v t="felix.20191128000818.1"><vh>Outline Editing Commands</vh>
<v t="felix.20191127004621.1"><vh>markPNode</vh></v>
<v t="felix.20191127235913.1"><vh>unmarkPNode</vh></v>
Expand Down Expand Up @@ -168,8 +179,7 @@ To contribute, see the official issues page for current list of 'TODO's at https
# and so this now app.commanders() yields this: return [f.c for f in g.app.windowList]

# did this add to existing array of g.app.commanders() ?
# print(str(self.g.app.commanders())) # test
print(*self.g.app.commanders(), sep='\n')
# print(*self.g.app.commanders(), sep='\n')

if self.commander:
self.commander.closed = False
Expand Down Expand Up @@ -235,7 +245,10 @@ To contribute, see the official issues page for current list of 'TODO's at https
else:
return self.outputPNodes([]) # default empty array
else:
return self.outputPNodes(self.yieldAllRootChildren()) # this outputs all Root Children
if self.commander.hoistStack:
return self.outputPNodes([self.commander.hoistStack[-1].p])
else:
return self.outputPNodes(self.yieldAllRootChildren()) # this outputs all Root Children

</t>
<t tx="felix.20191126232434.17">def getParent(self, p_ap):
Expand Down Expand Up @@ -449,7 +462,7 @@ if __name__ == '__main__':
'headline': stack_v.h,
} for (stack_v, stack_childIndex) in p.stack],
}
# TODO : (MAYBE) Convert all those booleans into an integer 'status' Flags
# TODO : Convert all those booleans into an 8 bit integer 'status' flag
if bool(p.b):
w_ap['hasBody'] = True
if p.hasChildren():
Expand Down Expand Up @@ -1418,6 +1431,7 @@ wsPort = 32125
w_states["canUndo"] = self.commander.canUndo()
w_states["canRedo"] = self.commander.canRedo()
w_states["canDemote"] = self.commander.canDemote()
w_states["canPromote"] = self.commander.canPromote()
w_states["canDehoist"] = self.commander.canDehoist()

except Exception as e:
Expand All @@ -1429,6 +1443,7 @@ wsPort = 32125
w_states["canUndo"] = False
w_states["canRedo"] = False
w_states["canDemote"] = False
w_states["canPromote"] = False
w_states["canDehoist"] = False

return self.sendLeoBridgePackage("states", w_states)
Expand Down Expand Up @@ -1505,6 +1520,55 @@ wsPort = 32125
'''Used to override g.app.gui.ask[XXX] dialogs answers'''
return "yes"

</t>
<t tx="felix.20200705193918.1"></t>
<t tx="felix.20200705193927.1">def gotoFirstVisible(self, p_ap):
"""Select the first visible node of the selected chapter or hoist."""
return self.outlineCommand("goToFirstVisibleNode", p_ap)

</t>
<t tx="felix.20200705201100.1">def gotoLastSibling(self, p_ap):
"""Select the last sibling of the selected node."""
return self.outlineCommand("goToLastSibling", p_ap)

</t>
<t tx="felix.20200705223430.1">def contractOrGoLeft(self, p_ap):
"""Simulate the left Arrow Key in folder of Windows Explorer."""
return self.outlineCommand("contractNodeOrGoToParent", p_ap)

</t>
<t tx="felix.20200705223521.1">def expandAndGoRight(self, p_ap):
"""If a node has children, expand it if needed and go to the first child."""
return self.outlineCommand("expandNodeAndGoToFirstChild", p_ap)

</t>
<t tx="felix.20200705223536.1">def gotoNextVisible(self, p_ap):
"""Select the visible node following the presently selected node."""
return self.outlineCommand("selectVisNext", p_ap)

</t>
<t tx="felix.20200705223541.1">def gotoPrevVisible(self, p_ap):
"""Select the visible node preceding the presently selected node."""
return self.outlineCommand("selectVisBack", p_ap)

</t>
<t tx="felix.20200705233325.1">def gotoLastVisible(self, p_ap):
"""Select the last visible node of selected chapter or hoist."""
return self.outlineCommand("goToLastVisibleNode", p_ap)

</t>
<t tx="felix.20200706030410.1">def gotoNextMarked(self, p_ap):
"""Select the next marked node."""
return self.outlineCommand("goToNextMarkedHeadline", p_ap)

</t>
<t tx="felix.20200706202247.1">def gotoNextClone(self, p_ap):
"""
Select the next node that is a clone of the selected node.
If the selected node is not a clone, do find-next-clone.
"""
return self.outlineCommand("goToNextClone", p_ap)

</t>
</tnodes>
</leo_file>
51 changes: 47 additions & 4 deletions leobridgeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,7 @@ def openFile(self, p_file):
# and so this now app.commanders() yields this: return [f.c for f in g.app.windowList]

# did this add to existing array of g.app.commanders() ?
# print(str(self.g.app.commanders())) # test
print(*self.g.app.commanders(), sep='\n')
# print(*self.g.app.commanders(), sep='\n')

if self.commander:
self.commander.closed = False
Expand Down Expand Up @@ -663,6 +662,7 @@ def getStates(self, p_package):
w_states["canUndo"] = self.commander.canUndo()
w_states["canRedo"] = self.commander.canRedo()
w_states["canDemote"] = self.commander.canDemote()
w_states["canPromote"] = self.commander.canPromote()
w_states["canDehoist"] = self.commander.canDehoist()

except Exception as e:
Expand All @@ -674,6 +674,7 @@ def getStates(self, p_package):
w_states["canUndo"] = False
w_states["canRedo"] = False
w_states["canDemote"] = False
w_states["canPromote"] = False
w_states["canDehoist"] = False

return self.sendLeoBridgePackage("states", w_states)
Expand Down Expand Up @@ -716,6 +717,45 @@ def outputPNodes(self, p_pList):
w_apList.append(self.p_to_ap(p))
return self.sendLeoBridgePackage("nodes", w_apList) # Multiple nodes, plural

def gotoFirstVisible(self, p_ap):
"""Select the first visible node of the selected chapter or hoist."""
return self.outlineCommand("goToFirstVisibleNode", p_ap)

def gotoLastVisible(self, p_ap):
"""Select the last visible node of selected chapter or hoist."""
return self.outlineCommand("goToLastVisibleNode", p_ap)

def gotoLastSibling(self, p_ap):
"""Select the last sibling of the selected node."""
return self.outlineCommand("goToLastSibling", p_ap)

def gotoNextVisible(self, p_ap):
"""Select the visible node following the presently selected node."""
return self.outlineCommand("selectVisNext", p_ap)

def gotoPrevVisible(self, p_ap):
"""Select the visible node preceding the presently selected node."""
return self.outlineCommand("selectVisBack", p_ap)

def gotoNextMarked(self, p_ap):
"""Select the next marked node."""
return self.outlineCommand("goToNextMarkedHeadline", p_ap)

def gotoNextClone(self, p_ap):
"""
Select the next node that is a clone of the selected node.
If the selected node is not a clone, do find-next-clone.
"""
return self.outlineCommand("goToNextClone", p_ap)

def contractOrGoLeft(self, p_ap):
"""Simulate the left Arrow Key in folder of Windows Explorer."""
return self.outlineCommand("contractNodeOrGoToParent", p_ap)

def expandAndGoRight(self, p_ap):
"""If a node has children, expand it if needed and go to the first child."""
return self.outlineCommand("expandNodeAndGoToFirstChild", p_ap)

def markPNode(self, p_ap):
'''Mark a node, don't select it'''
if p_ap:
Expand Down Expand Up @@ -959,7 +999,10 @@ def getChildren(self, p_ap):
else:
return self.outputPNodes([]) # default empty array
else:
return self.outputPNodes(self.yieldAllRootChildren()) # this outputs all Root Children
if self.commander.hoistStack:
return self.outputPNodes([self.commander.hoistStack[-1].p])
else:
return self.outputPNodes(self.yieldAllRootChildren()) # this outputs all Root Children

def getParent(self, p_ap):
'''EMIT OUT the parent of a node, as an array, even if unique or empty'''
Expand Down Expand Up @@ -1163,7 +1206,7 @@ def p_to_ap(self, p):
'headline': stack_v.h,
} for (stack_v, stack_childIndex) in p.stack],
}
# TODO : (MAYBE) Convert all those booleans into an integer 'status' Flags
# TODO : Convert all those booleans into an 8 bit integer 'status' flag
if bool(p.b):
w_ap['hasBody'] = True
if p.hasChildren():
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b520073

Please sign in to comment.