Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.browser_modules
lib
*.log
*-app/*
!*-app/package.json
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Browser Backend",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/browser-app/lib/**/*.js",
"${workspaceRoot}/browser-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/electron-app/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
120 changes: 120 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Emacs Extension
The example of how to build the Theia-based applications with the emacs-extension.

## Getting started

Install [nvm](https://github.com/creationix/nvm#install-script).

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash

Install npm and node.

nvm install 8
nvm use 8

Install yarn.

npm install -g yarn

## Running the browser example

yarn rebuild:browser
cd browser-app
yarn start

Open http://localhost:3000 in the browser.

## Running the Electron example

yarn rebuild:electron
cd electron-app
yarn start

## Developing with the browser example

Start watching of the emacs extension.

cd emacs-extension
yarn watch

Start watching of the browser example.

yarn rebuild:browser
cd browser-app
yarn watch

Launch `Start Browser Backend` configuration from VS code.

Open http://localhost:3000 in the browser.

## Developing with the Electron example

Start watching of the emacs-extension.

cd emacs-extension
yarn watch

Start watching of the electron example.

yarn rebuild:electron
cd electron-app
yarn watch

Launch `Start Electron Backend` configuration from VS code.

## Publishing emacs-extension

Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).

npm login

Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).

npx lerna publish

### Operation
Use Shift+DEL to cut to clipboard, Shift+Insert to paste from clipboard.

### Move command
|Command | Desc |
|---------------|---------------------------------------------------|
| `C-f` | Move forward |
| `C-b` | Move backward |
| `M-n` | Move to the next line (C+n - new tab in browser) |
| `C-p` | Move to the previous line |
| `C-a` | Move to the beginning of line |
| `C-e` | Move to the end of line |
| `M-f` | Move forward by one word unit |
| `M-b` | Move backward by one word unit |
| `M->` | Move to the end of buffer |
| `M-<` | Move to the beginning of buffer |
| `C-v` | Scroll down by one screen unit |
| `M-v` | Scroll up by one screen unit |
| `M-g g` | Jump to line (command palette) |


### Search Command
|Command | Desc |
|---------------|---------------------------------------------------|
| `C-s` | Search forward |
| `C-r` | Search backward |
| `C-M-n` | Add selection to next find match |

### Edit command
|Command | Desc |
|---------------|---------------------------------------------------|
| `C-d` | Delete right (DEL) |
| `C-h` | Delete left (BACKSPACE) |
| `M-d` | Delete word |
| `C-k` | Kill to line end |
| `C-x h` | Select All |
| `C-x u (C-/)` | Undo |
| `C-;` | Toggle line comment in and out |
| `M-;` | Toggle region comment in and out |

### Other command
|Command | Desc |
|---------------|---------------------------------------------------|
| `M-x` | Open command palette |
| `C-x C-s` | Save |
| `C-x b` | QuickOpen a file |
33 changes: 33 additions & 0 deletions browser-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"private": true,
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "0.3.12",
"@theia/filesystem": "0.3.12",
"@theia/file-search": "0.3.12",
"@theia/workspace": "0.3.12",
"@theia/preferences": "0.3.12",
"@theia/navigator": "0.3.12",
"@theia/process": "0.3.12",
"@theia/terminal": "0.3.12",
"@theia/editor": "0.3.12",
"@theia/languages": "0.3.12",
"@theia/markers": "0.3.12",
"@theia/monaco": "0.3.12",
"@theia/typescript": "0.3.12",
"@theia/messages": "0.3.12",
"emacs-extension": "0.0.0"
},
"devDependencies": {
"@theia/cli": "0.3.12"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "browser"
}
}
33 changes: 33 additions & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"private": true,
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "0.3.12",
"@theia/filesystem": "0.3.12",
"@theia/file-search": "0.3.12",
"@theia/workspace": "0.3.12",
"@theia/preferences": "0.3.12",
"@theia/navigator": "0.3.12",
"@theia/process": "0.3.12",
"@theia/terminal": "0.3.12",
"@theia/editor": "0.3.12",
"@theia/languages": "0.3.12",
"@theia/markers": "0.3.12",
"@theia/monaco": "0.3.12",
"@theia/typescript": "0.3.12",
"@theia/messages": "0.3.12",
"emacs-extension": "0.0.0"
},
"devDependencies": {
"@theia/cli": "0.3.12"
},
"scripts": {
"prepare": "theia build",
"start": "theia start",
"watch": "theia build --watch"
},
"theia": {
"target": "electron"
}
}
31 changes: 31 additions & 0 deletions emacs-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "emacs-extension",
"keywords": [
"theia-extension"
],
"version": "0.0.0",
"files": [
"lib",
"src"
],
"dependencies": {
"@theia/core": "0.3.12",
"@theia/file-search": "0.3.12",
"@theia/monaco": "0.3.12"
},
"devDependencies": {
"rimraf": "2.6.2",
"typescript": "2.7.2"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
},
"theiaExtensions": [
{
"frontend": "lib/browser/emacs-frontend-module"
}
]
}
35 changes: 35 additions & 0 deletions emacs-extension/src/browser/editor-agent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*********************************************************************
* Copyright (c) 2018 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import { injectable, inject } from "inversify";
import { EditorManager } from "@theia/editor/lib/browser";
import { MonacoEditor } from "@theia/monaco/lib/browser/monaco-editor";

@injectable()
export class EditorAgent {
@inject(EditorManager) protected readonly editorManager!: EditorManager;

getActiveEditor(): MonacoEditor | undefined {
const editorWidget = this.editorManager.activeEditor!;
const activeEditor = editorWidget.editor;

return activeEditor instanceof MonacoEditor ? activeEditor as MonacoEditor : undefined;
}

isEditorFocused(): boolean {
const widget = this.editorManager.activeEditor;
return !!widget && widget.editor.isFocused();
}

executeCommand(commandId: string) {
const editor = this.getActiveEditor()!;
editor.commandService.executeCommand(commandId);
}
}
Loading