Skip to content

Commit d55d5e7

Browse files
committed
v1.4.2
1 parent d561f69 commit d55d5e7

11 files changed

Lines changed: 3398 additions & 3265 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
## Changelog
2-
- Add: Discord RPC
2+
- Fixed: Now you can stop running process, in case you run infinite process
3+
- Improved: Buffer size increased

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Colon is a flexible text editor, built on [Electron](https://github.com/electron
66

77
### macOS
88

9-
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.4.1/Colon-1.4.1.dmg) for mac.
9+
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.4.2/Colon-1.4.2.dmg) for mac.
1010

1111
Colon will automatically update when a new release is available.
1212

1313
### Windows
1414

15-
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.4.1/Colon-Setup-1.4.1.exe) for windows.
15+
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.4.2/Colon-Setup-1.4.2.exe) for windows.
1616

1717
Colon will automatically update when a new release is available.
1818

1919
### Linux
2020

21-
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.4.1/Colon-1.4.1-x86_64.AppImage) for linux.
21+
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.4.2/Colon-1.4.2-x86_64.AppImage) for linux.
2222

2323
## License
2424

assets/css/editor.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,15 @@ input, button, textarea, :focus {
253253
vertical-align: middle;
254254
}
255255

256-
.run-button:{
256+
.run-button{
257257
cursor: pointer;
258258
}
259+
260+
.stop-button{
261+
cursor: pointer;
262+
width: 20px;
263+
margin:10px;
264+
}
259265
.close {
260266
position: relative;
261267
/* display: inline-block;
@@ -454,4 +460,11 @@ input, button, textarea, :focus {
454460
}
455461
::-webkit-outer-spin-button, ::-webkit-inner-spin-button{
456462
-webkit-appearance: none;
463+
}
464+
465+
.hide{
466+
display: none;
467+
}
468+
.show{
469+
display: block;
457470
}

assets/icons/stop-button.svg

Lines changed: 2 additions & 0 deletions
Loading

assets/js/discord-rpc.js

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,44 @@ settings_file = JSON.parse(settings_file);
88

99

1010
// console.log('loading discord-rpc.js');
11-
12-
const clientId = '544485914198409217';
13-
14-
DiscordRPC.register(clientId);
15-
16-
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
17-
const startTimestamp = new Date();
18-
19-
async function setActivity() {
20-
if (!rpc || !mainWindow || ! settings_file.discord['discord-rpc-enable']) {
21-
return;
22-
}
23-
24-
// const boops = await mainWindow.webContents.executeJavaScript('window.boops');
25-
functions.getCurrentWorkingFile(function(filename){
26-
// console.log('hello');
27-
rpc.setActivity({
28-
details: `Working on ${filename}`,
29-
state: settings_file.discord['discord-status'],
30-
startTimestamp,
31-
largeImageKey: 'icon',
32-
largeImageText: 'A flexible text editor',
33-
smallImageKey: 'snek_small',
34-
smallImageText: 'A flexible text editor',
35-
instance: false,
36-
});
37-
})
38-
39-
}
40-
41-
rpc.on('ready', () => {
42-
setActivity();
43-
44-
// activity can only be set every 15 seconds
45-
setInterval(() => {
46-
setActivity();
47-
}, 15e3);
48-
});
49-
50-
rpc.login({ clientId }).catch(console.error);
11+
if (settings_file.discord['discord-rpc-enable']){
12+
const clientId = '544485914198409217';
13+
14+
DiscordRPC.register(clientId);
15+
16+
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
17+
const startTimestamp = new Date();
18+
19+
async function setActivity() {
20+
if (!rpc || !mainWindow || ! settings_file.discord['discord-rpc-enable']) {
21+
return;
22+
}
23+
24+
// const boops = await mainWindow.webContents.executeJavaScript('window.boops');
25+
functions.getCurrentWorkingFile(function(filename){
26+
// console.log('hello');
27+
rpc.setActivity({
28+
details: `Working on ${filename}`,
29+
state: settings_file.discord['discord-status'],
30+
startTimestamp,
31+
largeImageKey: 'icon',
32+
largeImageText: 'A flexible text editor',
33+
smallImageKey: 'snek_small',
34+
smallImageText: 'A flexible text editor',
35+
instance: false,
36+
});
37+
})
38+
39+
}
40+
41+
rpc.on('ready', () => {
42+
setActivity();
43+
44+
// activity can only be set every 15 seconds
45+
setInterval(() => {
46+
setActivity();
47+
}, 15e3);
48+
});
49+
50+
rpc.login({ clientId }).catch(console.error);
51+
}

assets/js/editor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,18 @@ function run(){
666666
ipc.send('save-data', data, file.path);
667667
let input = $('#input').val();
668668
ipc.send('runProgram',input,file.path);
669+
$('.run-button').addClass('hide');
670+
$('.stop-button').removeClass('hide');
671+
}
672+
673+
function stop(){
674+
ipc.send('stopProgram');
669675
}
670676

671677
ipc.on('runProgramStatus',function(event,output){
672678
$('#output').html(output);
679+
$('.run-button').removeClass('hide');
680+
$('.stop-button').addClass('hide');
673681
});
674682

675683
// error dialog

menu/functions.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ const ipc = require('electron').ipcMain;
44
const path = require('path');
55
const util = require('util');
66
const exec = require('child_process').exec;
7+
const psTree = require('ps-tree');
78

89
// console.log('loading functions-rpc.js');
910

1011
// const spawn = require('child_process').spawn;
1112

1213
global.filename = undefined;
14+
var child;
1315

1416
function openFileFromSidebar(filepath){
1517
// console.log(filepath);
@@ -245,6 +247,31 @@ ipc.on('close-app',function(event){
245247
app.quit();
246248
})
247249

250+
function killProcess (pid, signal, callback) {
251+
signal = signal || 'SIGKILL';
252+
callback = callback || function () {};
253+
var killTree = true;
254+
if(killTree) {
255+
psTree(pid, function (err, children) {
256+
[pid].concat(
257+
children.map(function (p) {
258+
return p.PID;
259+
})
260+
).forEach(function (tpid) {
261+
try { process.kill(tpid, signal) }
262+
catch (ex) { }
263+
});
264+
callback();
265+
});
266+
} else {
267+
try { process.kill(pid, signal) }
268+
catch (ex) { }
269+
callback();
270+
}
271+
};
272+
273+
274+
248275
function makeCommand(filepath){
249276
// console.log(filepath)
250277
let filename = path.basename(filepath);
@@ -319,24 +346,37 @@ ipc.on('runProgram',function(event,input,filepath){
319346
mainWindow.webContents.send('runProgramStatus',err.message);
320347
// console.log(err.message);
321348
}else{
322-
let child = exec(command,{maxBuffer: 1024 * 500} , function(err,stdout,stderr){
349+
child = exec(command,{maxBuffer: 1024 * 10000} , function(err,stdout,stderr){
323350
if(err){
351+
console.log(err, 'line 324');
352+
killProcess(child.pid);
353+
// child.kill();
354+
// console.log(child);
324355
console.log(err);
356+
if(child.killed){
357+
err.message = "Process has been killed"
358+
}
325359
mainWindow.webContents.send('runProgramStatus',err.message);
326360
// console.log(err.message.split('\n')[1]);
327361
}else{
328362
mainWindow.webContents.send('runProgramStatus',stdout);
329363
// console.log(stdout);
330-
var to = setTimeout(function(){
331-
child.kill();
332-
}, 2000);
333364
}
334365
});
335366
}
336367
});
337368
}
338369
}
339370
});
371+
372+
ipc.on('stopProgram', function(event){
373+
if(child){
374+
child.killed = true;
375+
killProcess(child.pid);
376+
377+
}
378+
});
379+
340380
ipc.on('settingsChangeTheme', (event, data)=>{
341381
let settings_file = fs.readFileSync(path.join(getUserDataPath(), 'settings.json'));
342382
settings_file = JSON.parse(settings_file);

0 commit comments

Comments
 (0)