Skip to content

Commit 1b65748

Browse files
committed
wip
1 parent 6189be6 commit 1b65748

File tree

6 files changed

+86
-6
lines changed

6 files changed

+86
-6
lines changed

package-lock.json

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
},
4545
"keywords": [],
4646
"dependencies": {
47-
"electron-squirrel-startup": "^1.0.1"
47+
"@xterm/xterm": "^5.5.0",
48+
"electron-squirrel-startup": "^1.0.1",
49+
"node-pty": "^1.1.0-beta30"
4850
}
4951
}

src/Ucm/WorkspaceScreen.elm

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
module Ucm.WorkspaceScreen exposing (..)
1+
port module Ucm.WorkspaceScreen exposing (..)
22

33
import Browser
44
import Code.BranchRef as BranchRef
55
import Code.CodebaseTree as CodebaseTree
66
import Code.Config
77
import Html exposing (Html, div, text)
8-
import Html.Attributes exposing (class)
8+
import Html.Attributes exposing (class, id)
9+
import Lib.Util as Util
910
import RemoteData exposing (RemoteData(..))
1011
import UI.AnchoredOverlay as AnchoredOverlay
1112
import UI.Button as Button
@@ -72,6 +73,7 @@ init appContext workspaceContext =
7273
, Cmd.batch
7374
[ Cmd.map CodebaseTreeMsg codebaseTreeCmd
7475
, Cmd.map WorkspacePanesMsg panesCmd
76+
, Util.delayMsg 5000 OpenTerminal
7577
]
7678
)
7779

@@ -88,6 +90,7 @@ type Msg
8890
| ToggleSidebar
8991
| ToggleRightPane
9092
| RefreshCodebase
93+
| OpenTerminal
9194
| Keydown KeyboardEvent.KeyboardEvent
9295
| CodebaseTreeMsg CodebaseTree.Msg
9396
| WorkspacePanesMsg WorkspacePanes.Msg
@@ -104,6 +107,9 @@ type OutMsg
104107
update : AppContext -> Msg -> Model -> ( Model, Cmd Msg, OutMsg )
105108
update appContext msg model =
106109
case msg of
110+
OpenTerminal ->
111+
( model, openTerminal "terminal-pane", None )
112+
107113
CodebaseTreeMsg codebaseTreeMsg ->
108114
let
109115
( codebaseTree, codebaseTreeCmd, outMsg ) =
@@ -388,6 +394,13 @@ update appContext msg model =
388394

389395

390396

397+
-- PORTS
398+
399+
400+
port openTerminal : String -> Cmd msg
401+
402+
403+
391404
-- SUBSCRIPTIONS
392405

393406

@@ -538,7 +551,10 @@ view appContext model =
538551
window_
539552

540553
content =
541-
[ Html.map WorkspacePanesMsg (WorkspacePanes.view model.panes) ]
554+
[ Html.map WorkspacePanesMsg
555+
(WorkspacePanes.view model.panes)
556+
, div [ id "terminal-pane" ] []
557+
]
542558
in
543559
window__
544560
|> Window.withTitlebarLeft (titlebarLeft model)

src/css/ucm/workspace-screen.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,12 @@
6363
color: var(--u-color_icon);
6464
}
6565
}
66+
67+
#terminal-pane {
68+
border: 1px solid red;
69+
position: absolute;
70+
bottom: 0;
71+
left: 0;
72+
right: 0;
73+
height: 300px;
74+
}

src/main.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { app, BrowserWindow } from 'electron';
2-
import path from 'node:path';
32
import started from 'electron-squirrel-startup';
3+
import * as os from 'os';
4+
import * as pty from 'node-pty';
45

56
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
67
if (started) {
@@ -50,3 +51,19 @@ app.on('window-all-closed', () => {
5051

5152
// In this file you can include the rest of your app's specific main process
5253
// code. You can also put them in separate files and import them here.
54+
//
55+
56+
// const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
57+
58+
// const ptyProcess = pty.spawn(shell, [], {});
59+
const ptyProcess = pty.spawn('bash', [], {});
60+
61+
/*
62+
ptyProcess.onData((data) => {
63+
process.stdout.write(data);
64+
});
65+
66+
ptyProcess.write('ls\r');
67+
ptyProcess.resize(100, 40);
68+
ptyProcess.write('ls\r');
69+
*/

src/renderer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import "./main.css";
1515
import * as AppError from "./Ucm/AppError";
1616
import * as AppSettings from "./Ucm/AppSettings";
1717
import * as Theme from "./Ucm/Theme";
18+
import "@xterm/xterm/css/xterm.css";
19+
import { Terminal } from "@xterm/xterm";
20+
1821

1922
// @ts-ignore
2023
import { Elm } from './Main.elm';
@@ -32,6 +35,8 @@ try {
3235
const appSettings = AppSettings.init();
3336
const operatingSystem = detectOs(window.navigator);
3437

38+
const terminal = new Terminal();
39+
3540
// -- Elm -------------------------------------------------------------------
3641
const flags = {
3742
operatingSystem: operatingSystem,
@@ -60,6 +65,13 @@ try {
6065
AppSettings.clear();
6166
window.location.reload();
6267
});
68+
69+
app.ports.openTerminal?.subscribe((targetId) => {
70+
const target = document.getElementById(targetId);
71+
if (target) {
72+
terminal.open(target);
73+
}
74+
});
6375
}
6476

6577
// -- CSS env classes -------------------------------------------------------

0 commit comments

Comments
 (0)