Skip to content
Merged
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
8 changes: 8 additions & 0 deletions src/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ <h1>SSH Lite Client</h1>
<button id="saveBtn">Save</button>
</div>
</div>
<div class="editor-tools">
<div class="editor-tool-buttons">
<button id="findBtn" class="ghost-btn">Find</button>
<button id="replaceBtn" class="ghost-btn">Replace</button>
<button id="goToLineBtn" class="ghost-btn">Go to line</button>
</div>
<span class="editor-shortcuts">Shortcuts: Ctrl/Cmd+F, Ctrl/Cmd+H, Ctrl/Cmd+G, Ctrl/Cmd+S</span>
</div>
<div id="editorHost" aria-label="File editor"></div>
<section id="terminalPane" class="terminal-pane hidden">
<div class="terminal-actions">
Expand Down
38 changes: 38 additions & 0 deletions src/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const fileList = document.getElementById('fileList');
const editorHost = document.getElementById('editorHost');
const saveBtn = document.getElementById('saveBtn');
const closeFileBtn = document.getElementById('closeFileBtn');
const findBtn = document.getElementById('findBtn');
const replaceBtn = document.getElementById('replaceBtn');
const goToLineBtn = document.getElementById('goToLineBtn');
const currentFileEl = document.getElementById('currentFile');
const editorTabBtn = document.getElementById('editorTabBtn');
const terminalTabBtn = document.getElementById('terminalTabBtn');
Expand Down Expand Up @@ -74,9 +77,12 @@ let suppressDirtyTracking = false;
function updateCurrentFileLabel() {
if (!currentFile) {
currentFileEl.textContent = 'No file open';
document.title = 'SSH Lite Client';
return;
}
currentFileEl.textContent = isDirty ? `${currentFile} *` : currentFile;
const fileName = currentFile.split('/').pop() || currentFile;
document.title = `${isDirty ? '* ' : ''}${fileName} - SSH Lite Client`;
}

async function ensureMonacoReady() {
Expand Down Expand Up @@ -192,6 +198,26 @@ function updateEditorTheme() {
monacoApi?.editor.setTheme(theme);
}

async function runEditorAction(kind) {
if (!(await ensureMonacoReady()) || !monacoEditor) return;
showEditorView();
monacoEditor.focus();

if (kind === 'find') {
monacoEditor.trigger('ui', 'actions.find', null);
return;
}

if (kind === 'replace') {
monacoEditor.trigger('ui', 'editor.action.startFindReplaceAction', null);
return;
}

if (kind === 'goto') {
monacoEditor.trigger('ui', 'editor.action.gotoLine', null);
}
}

function focusEditorSoon() {
const tryFocus = () => {
document.body.classList.remove('resizing');
Expand Down Expand Up @@ -774,6 +800,18 @@ closeFileBtn.onclick = async () => {
closeCurrentFile();
};

findBtn.onclick = () => {
void runEditorAction('find');
};

replaceBtn.onclick = () => {
void runEditorAction('replace');
};

goToLineBtn.onclick = () => {
void runEditorAction('goto');
};

pickKeyBtn.onclick = async () => {
const res = await window.api.pickPrivateKey();
if (!res.ok) {
Expand Down
23 changes: 23 additions & 0 deletions src/renderer/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,25 @@ body.resizing {
gap: 8px;
}

.editor-tools {
border-bottom: 1px solid var(--border);
padding: 8px 10px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
}

.editor-tool-buttons {
display: flex;
gap: 6px;
}

.editor-shortcuts {
font-size: 12px;
color: var(--muted);
}

.view-tabs {
display: flex;
gap: 6px;
Expand Down Expand Up @@ -449,4 +468,8 @@ body.resizing {
.editor-top {
flex-wrap: wrap;
}

.editor-tools {
flex-wrap: wrap;
}
}