Skip to content

Commit

Permalink
added some more shortkeys found by trial/error
Browse files Browse the repository at this point in the history
  • Loading branch information
tmhglnd committed Jul 17, 2024
1 parent f4143fa commit a9a14cf
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 7 deletions.
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,39 @@ Web-based P2P collaborative editor for live coding music and graphics

## Usage

### Shortkeys
### Keybindings

*Some shortkeys may differ depending on the language/target you choose*
*Some keybindings may differ depending on the language/target you choose*

| Keymap | Function |
| Keybinding | Function |
| - | - |
| `Alt/Option` `Enter` | Evaluate all |
| `Ctrl/Cmd` `Enter` | Evaluate block, Evaluate selection |
| `Shift` `Enter` | Evaluate line |
| `Ctrl/Cmd/Option/Alt` `.` | Silence (output depends on language) |
| `alt/option` `enter` | Evaluate all |
| `ctrl/cmd` `enter` | Evaluate block, Evaluate selection |
| `shift` `enter` | Evaluate line |
| `ctrl/cmd/option/alt` `.` | Silence (output depends on language) |
| `cmd/ctrl` `shift` `h` | Show/Hide editor panels |
| `cmd/ctrl` `x` | Cut selected text |
| `cmd/ctrl` `c` | Copy selected text |
| `cmd/ctrl` `v` | Paste cut/copied text |
| `cmd/ctrl` `z/u` | Undo edit |
| `cmd/ctrl` `shift` `z/u` | Redo edit |
| `cmd/ctrl` `}` | add indentation |
| `cmd/ctrl` `{` | remove indentation |
| `cmd/ctrl` `f` | search and replace |

<!-- On Mac (not tested on Windows/Linux)
| `ctrl` `e` | jump to end of the line |
| `ctrl` `a` | jump to the beginning of the line |
| `ctrl` `t` | move character one step right |
| `ctrl` `y` | delete selected text |
| `ctrl` `o` | insert linebreak |
| `ctrl` `d` | delete character on the right of cursor |
| `ctrl` `h` | backspace character on the left of cursor |
| `ctrl` `l` | select whole line after cursor |
| `ctrl` `v` | jump to bottom end |
| `ctrl` `b` | move cursor to the left |
| `ctrl` `n` | move cursor down | -->

### Public server

Expand Down
81 changes: 81 additions & 0 deletions packages/repl/lib/repl/dummy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { BaseREPL, BaseREPLContext } from "../repl.js";
import osc from "osc";
import debugModule from "debug";

const debug = debugModule("flok:repl:dummy");

const { UDPPort } = osc;

// A dummy/free/open REPL
// The repl doesn't have any specific language, it just forwards the
// text to an assigned OSC port 3001
// The address used is /flok

// $ flok-repl -t free
//
// Sends the code over OSC to port 3001 on localhost
// Port can be assigned by choice
//
class DummyREPL extends BaseREPL {
udpPort: typeof UDPPort;
port: number;
started: boolean;
portReady: boolean;

constructor(ctx: BaseREPLContext) {
super(ctx);

this.port = 3001;
this.started = false;
this.portReady = false;
}

start() {
super.start();

this.udpPort = new UDPPort({
metadata: true,
});

// Listen for incoming OSC messages.
this.udpPort.on("message", function (oscMsg, timeTag, info) {
debug("An OSC message just arrived!", oscMsg);
debug("Remote info is: ", info);
});

// Open the socket.
this.udpPort.open();

// When the port is read, send an OSC message
const that = this;
this.udpPort.on("ready", function () {
that.portReady = true;
});

this.started = true;
}

write(body: string) {
if (!this.portReady) {
debug("UDP Port is not ready yet.");
return;
}

const newBody = this.prepare(body);
const obj = {
address: "/flok",
args: [
{
type: "s",
value: newBody,
},
],
};
this.udpPort.send(obj, "127.0.0.1", this.port);

const lines = newBody.split("\n");
this.emitter.emit("data", { type: "stdin", lines });
}
}

export default DummyREPL;

0 comments on commit a9a14cf

Please sign in to comment.