Skip to content

Commit

Permalink
v1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Chhekur committed Mar 2, 2019
1 parent d561f69 commit d55d5e7
Show file tree
Hide file tree
Showing 11 changed files with 3,398 additions and 3,265 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## Changelog
- Add: Discord RPC
- Fixed: Now you can stop running process, in case you run infinite process
- Improved: Buffer size increased
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ Colon is a flexible text editor, built on [Electron](https://github.com/electron

### macOS

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

Colon will automatically update when a new release is available.

### Windows

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

Colon will automatically update when a new release is available.

### Linux

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.
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.

## License

Expand Down
15 changes: 14 additions & 1 deletion assets/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,15 @@ input, button, textarea, :focus {
vertical-align: middle;
}

.run-button:{
.run-button{
cursor: pointer;
}

.stop-button{
cursor: pointer;
width: 20px;
margin:10px;
}
.close {
position: relative;
/* display: inline-block;
Expand Down Expand Up @@ -454,4 +460,11 @@ input, button, textarea, :focus {
}
::-webkit-outer-spin-button, ::-webkit-inner-spin-button{
-webkit-appearance: none;
}

.hide{
display: none;
}
.show{
display: block;
}
2 changes: 2 additions & 0 deletions assets/icons/stop-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 41 additions & 40 deletions assets/js/discord-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,44 @@ settings_file = JSON.parse(settings_file);


// console.log('loading discord-rpc.js');

const clientId = '544485914198409217';

DiscordRPC.register(clientId);

const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();

async function setActivity() {
if (!rpc || !mainWindow || ! settings_file.discord['discord-rpc-enable']) {
return;
}

// const boops = await mainWindow.webContents.executeJavaScript('window.boops');
functions.getCurrentWorkingFile(function(filename){
// console.log('hello');
rpc.setActivity({
details: `Working on ${filename}`,
state: settings_file.discord['discord-status'],
startTimestamp,
largeImageKey: 'icon',
largeImageText: 'A flexible text editor',
smallImageKey: 'snek_small',
smallImageText: 'A flexible text editor',
instance: false,
});
})

}

rpc.on('ready', () => {
setActivity();

// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});

rpc.login({ clientId }).catch(console.error);
if (settings_file.discord['discord-rpc-enable']){
const clientId = '544485914198409217';

DiscordRPC.register(clientId);

const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();

async function setActivity() {
if (!rpc || !mainWindow || ! settings_file.discord['discord-rpc-enable']) {
return;
}

// const boops = await mainWindow.webContents.executeJavaScript('window.boops');
functions.getCurrentWorkingFile(function(filename){
// console.log('hello');
rpc.setActivity({
details: `Working on ${filename}`,
state: settings_file.discord['discord-status'],
startTimestamp,
largeImageKey: 'icon',
largeImageText: 'A flexible text editor',
smallImageKey: 'snek_small',
smallImageText: 'A flexible text editor',
instance: false,
});
})

}

rpc.on('ready', () => {
setActivity();

// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});

rpc.login({ clientId }).catch(console.error);
}
8 changes: 8 additions & 0 deletions assets/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,18 @@ function run(){
ipc.send('save-data', data, file.path);
let input = $('#input').val();
ipc.send('runProgram',input,file.path);
$('.run-button').addClass('hide');
$('.stop-button').removeClass('hide');
}

function stop(){
ipc.send('stopProgram');
}

ipc.on('runProgramStatus',function(event,output){
$('#output').html(output);
$('.run-button').removeClass('hide');
$('.stop-button').addClass('hide');
});

// error dialog
Expand Down
48 changes: 44 additions & 4 deletions menu/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const ipc = require('electron').ipcMain;
const path = require('path');
const util = require('util');
const exec = require('child_process').exec;
const psTree = require('ps-tree');

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

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

global.filename = undefined;
var child;

function openFileFromSidebar(filepath){
// console.log(filepath);
Expand Down Expand Up @@ -245,6 +247,31 @@ ipc.on('close-app',function(event){
app.quit();
})

function killProcess (pid, signal, callback) {
signal = signal || 'SIGKILL';
callback = callback || function () {};
var killTree = true;
if(killTree) {
psTree(pid, function (err, children) {
[pid].concat(
children.map(function (p) {
return p.PID;
})
).forEach(function (tpid) {
try { process.kill(tpid, signal) }
catch (ex) { }
});
callback();
});
} else {
try { process.kill(pid, signal) }
catch (ex) { }
callback();
}
};



function makeCommand(filepath){
// console.log(filepath)
let filename = path.basename(filepath);
Expand Down Expand Up @@ -319,24 +346,37 @@ ipc.on('runProgram',function(event,input,filepath){
mainWindow.webContents.send('runProgramStatus',err.message);
// console.log(err.message);
}else{
let child = exec(command,{maxBuffer: 1024 * 500} , function(err,stdout,stderr){
child = exec(command,{maxBuffer: 1024 * 10000} , function(err,stdout,stderr){
if(err){
console.log(err, 'line 324');
killProcess(child.pid);
// child.kill();
// console.log(child);
console.log(err);
if(child.killed){
err.message = "Process has been killed"
}
mainWindow.webContents.send('runProgramStatus',err.message);
// console.log(err.message.split('\n')[1]);
}else{
mainWindow.webContents.send('runProgramStatus',stdout);
// console.log(stdout);
var to = setTimeout(function(){
child.kill();
}, 2000);
}
});
}
});
}
}
});

ipc.on('stopProgram', function(event){
if(child){
child.killed = true;
killProcess(child.pid);

}
});

ipc.on('settingsChangeTheme', (event, data)=>{
let settings_file = fs.readFileSync(path.join(getUserDataPath(), 'settings.json'));
settings_file = JSON.parse(settings_file);
Expand Down
Loading

0 comments on commit d55d5e7

Please sign in to comment.