Skip to content

Commit

Permalink
Merge pull request #21 from ste2425/copy-log
Browse files Browse the repository at this point in the history
added ability to copy log
  • Loading branch information
ste2425 authored Jul 5, 2019
2 parents 8228385 + f0b778c commit 6b47911
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 30 deletions.
12 changes: 6 additions & 6 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## Version 0.1.7
## Version 0.2.0
---

Release highlights:

* Fixed potential memory leak issue
* Added copying of logs to the clipboard

---

# Memory Leak
# Copying logs to the clipboard

When teminating an application, either by stoppingit directly or by purging dotnet apps it was possible for some satellite proccess to remain.
It is now possible to copy the entire log of a terminal to the systems clipboard. This also includes the selected text.

These will now be terminated also.
To copy only the selected text, first highlight the desired text then right click on the terminal.

More information can be found [In the Wiki](https://github.com/ste2425/DotnetRunner/wiki/Node-PTY-and-satellite-Dotnet-processes){.open-external}
To copy the entire log, select `Copy Log` from the drop down menu of each terminal.
37 changes: 30 additions & 7 deletions app/Components/runner/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Terminal = require('xterm').Terminal;
const fit = require('xterm/lib/addons/fit/fit');
const fullScreen = require('xterm/lib/addons/fullscreen/fullscreen');
const debounce = require('../../utils/debounce');
const { clipboard } = require('electron');

Terminal.applyAddon(fit);
Terminal.applyAddon(fullScreen);
Expand Down Expand Up @@ -47,15 +48,16 @@ module.exports = class RunnerElement extends WebComponentBase {
const clean = shadow.querySelector('.clean');
const full = shadow.querySelector('.full');
const terminal = shadow.querySelector('.terminals');
const copyLogBtn = shadow.querySelectorAll('.copy-log');
const closeFullScreen = shadow.querySelector('.close-fullscreen');

clearLog.addEventListener('click', () => this.clearData());
clean.addEventListener('click', () => this.clean());
copyLogBtn.forEach(x => x.addEventListener('click', () => this.exportLog()));

terminal.addEventListener('click', (e) => {
if (e.target.classList.contains('full-screen')) {
terminal.classList.remove('full-screen');
this._terminalProcess.fit();
}
closeFullScreen.addEventListener('click', (e) => {
terminal.classList.remove('full-screen');
this._terminalProcess.fit();
});

full.addEventListener('click', () => {
Expand All @@ -78,6 +80,15 @@ module.exports = class RunnerElement extends WebComponentBase {
executeOnFirstRun: true
}));

terminal.addEventListener('contextmenu', () => {
const selection = this._terminalProcess.getSelection();

if (selection)
clipboard.writeText(selection.trim());

this._terminalProcess.clearSelection();
});

this.resize();
}

Expand Down Expand Up @@ -180,11 +191,23 @@ module.exports = class RunnerElement extends WebComponentBase {

onTerminate() {
if (!this._runningProccess || this.state === RunnerElement.states.stopped || this.state === RunnerElement.states.stopping)
return Promise.resolve();
return;

this.setState(RunnerElement.states.stopping);

return this._runningProccess.kill();
this._runningProccess.kill();
}

exportLog() {
if (!this._terminalProcess)
return;

this._terminalProcess.selectAll();
const log = this._terminalProcess.getSelection();
this._terminalProcess.clearSelection();

if (log)
clipboard.writeText(log.trim());
}

set name(value) {
Expand Down
26 changes: 11 additions & 15 deletions app/Components/runner/runner.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ span.badge {
border: 1px solid rgba(128, 128, 128, 0.35);
}

.terminals:not(.full-screen) .full-screen-options {
display: none;
}

.terminals.full-screen .full-screen-options {
position: absolute;
top: 5px;
z-index: 5;
right: 20px;
}

.log-item.error {
color: red;
}
Expand All @@ -30,21 +41,6 @@ span.badge {
z-index: 200;
}

.terminals.full-screen::before {
content: 'Close';
display: block;
position: absolute;
top: 0px;
z-index: 5;
right: 20px;
color: white;
cursor: pointer;
border-radius: 3px;
border: 1px solid white;
padding: 5px;
margin: 3px;
}

.terminals {
position: relative;
}
5 changes: 5 additions & 0 deletions app/Components/runner/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1 class="name"></h1>
<button class="action btn btn-sm btn-primary">Start</button>
<button class="full btn btn-sm btn-dark">Full Screen</button>
<drop-down class="group-left">
<button class="copy-log btn-sm">Copy Log</button>
<button class="clean btn-sm">Clean</button>
<button class="clear-log btn-sm">Clear Log</button>
</drop-down>
Expand All @@ -25,4 +26,8 @@ <h1 class="name"></h1>
<span class="state badge"></span>
</div>
<div class="terminals">
<div class="btn-group full-screen-options">
<button class="close-fullscreen btn btn-secondary">Close</button>
<button class="copy-log btn btn-info">Copy Log</button>
</div>
</div>
2 changes: 1 addition & 1 deletion app/browserWindows/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function onReloadDataIPC() {

onTerminateAll()
.finally(() => {
remote.getCurrentWindow().close();
process.nextTick(() => remote.getCurrentWindow().close());
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dotnet-runner",
"version": "0.1.7",
"version": "0.2.0",
"description": "Electron application to launch dotnet applications",
"main": "startup.js",
"scripts": {
Expand Down

0 comments on commit 6b47911

Please sign in to comment.