Skip to content

Commit

Permalink
1.3.1 & Fixed: when open a huge directory, it will make colon slow
Browse files Browse the repository at this point in the history
  • Loading branch information
Chhekur committed Jan 31, 2019
1 parent 05b6bc8 commit 27b53fa
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 36 deletions.
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
## Changelog
- Themes Implemented
- Template Implemented
- Settings Panel Implemented
- Hint on Sidebar
- Multiple instances of same file has been fixed
- Fixed: when open a huge directory, it will make colon slow
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.3.0/Colon-1.3.0.dmg) for mac.
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-1.3.1.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.3.0/Colon-Setup-1.3.0.exe) for windows.
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-Setup-1.3.1.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.3.0/Colon-1.3.0-x86_64.AppImage) for linux.
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-1.3.1-x86_64.AppImage) for linux.

## License

Expand Down
67 changes: 53 additions & 14 deletions assets/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,24 +347,63 @@ ipc.on('closeFile',function(event){
closeCurrentFile(file);
});

// generate valid ID from path

function pathToId(filepath){
filepath = filepath.replace(/ /g, '_');
filepath = filepath.replace(/:/g, '');
let tokens = filepath.split(path.sep);
let ID = '';
for(let i = 0; i < tokens.length; i++){
ID += tokens[i];
}
// console.log(ID);
return ID;
}



// open folder
ipc.on('openFolder', function(event,structure){
let response = '<ul class="file-tree"><li><a href="#"><span class = "label">' + structure.name + '</span></a><ul>';
response += makeDirectoryTree(structure.children);
response += '</ul>';
$('#project-structure').html(response);
// console.log($('#project-structure'));
$(".file-tree").filetree();
openProjectStructure(true);
});

// create directory for specific Dirpath

function createDirectoryForSpecificDirpath(folder){
// console.log(folder.getAttribute('data-path'));
// console.log($('#' + pathToId(folder.getAttribute('data-path'))).length);
// console.log($('#' + pathToId(folder.getAttribute('data-path'))).children());

if($('#' + pathToId(folder.getAttribute('data-path'))).children().length == 0){
ipc.send('createDirectoryForSpecificDirpath', folder.getAttribute('data-path'));
}
}

ipc.on('getDirectroyForSpecificDirpath', function(event, structure){
// console.log(structure);
// console.log(structure.path);
// console.log(makeDirectoryTree(structure.children));
// console.log($('#' + structure.path.replace(/ /g, '_')));
// console.log($('#askdfhkjashdfkjasdf'))

$('#' + pathToId(structure.path)).html(makeDirectoryTree(structure.children));
$('#' + pathToId(structure.path)).filetree();
});
// create tree structure for opened folder

function makeDirectoryTree(structure){
var response = "";
structure.forEach(function(obj){
if(obj.type == "folder"){
response += '<li><a href="#"><span class = "label">'+ obj.name + '</span></a><ul>' + makeDirectoryTree(obj.children) + '</ul></li>';
// response += '<li><a href="#"><span class = "label">'+ obj.name + '</span></a><ul>' + makeDirectoryTree(obj.children) + '</ul></li>';
response += '<li><a href="#"><span class = "label" onclick = "createDirectoryForSpecificDirpath(this)" data-path = "' + obj.path + '">'+ obj.name + '</span></a><ul id = "' + pathToId(obj.path) + '"></ul></li>';
}else{
response += '<li data-extension = "'+obj.name+'"><a href="#"><span onclick = "openFileFromSidebar(this)" class = "label" data-name = "'+ obj.name +'" data-path = "'+ obj.path +'">' + obj.name + '</span></a></li>';
}
Expand Down Expand Up @@ -591,19 +630,19 @@ $(".panel-middle").resizable({
// create directory tree structure


$(document).ready(function() {
$(".file-tree").filetree();
});
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36251023-1']);
_gaq.push(['_setDomainName', 'jqueryscript.net']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// $(document).ready(function() {
// $(".file-tree").filetree();
// });
// var _gaq = _gaq || [];
// _gaq.push(['_setAccount', 'UA-36251023-1']);
// _gaq.push(['_setDomainName', 'jqueryscript.net']);
// _gaq.push(['_trackPageview']);

// (function() {
// var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
// ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
// var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
// })();

// run program
function run(){
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function createWindow () {
slashes: true
}))
// Open the DevTools.
// mainWindow.webContents.openDevTools()
mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
Expand Down
40 changes: 29 additions & 11 deletions menu/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,47 @@ function openFolder(){
structure = dirTree(dir[0]);
// openFolderHelper(dir[0],structure);
// console.log(typeof structure);
// console.log(structure);
mainWindow.webContents.send('openFolder',structure);
}
// console.log()
}

ipc.on('createDirectoryForSpecificDirpath', function(event, folderpath){
// console.log(dirTree(folderpath));
mainWindow.webContents.send('getDirectroyForSpecificDirpath', dirTree(folderpath));
});

function dirTree(filename) {
var stats = fs.lstatSync(filename),
info = {
path: filename,
name: path.basename(filename)
};

if (stats.isDirectory()) {
info.type = "folder";
info.children = fs.readdirSync(filename).map(function(child) {
return dirTree(path.join(filename,child));
});
} else {
// Assuming it's a file. In real life it could be a symlink or
// something else!
info.type = "file";
}
// console.log(stats);
let files = fs.readdirSync(filename);
let temp_str = [];
files.forEach(function(file){
temp_str.push({
path : path.join(filename, file),
name : file,
type : ((fs.lstatSync(path.join(filename, file)).isDirectory()) ? "folder" : "file")
});
});
info.children = temp_str;
// if (stats.isDirectory()) {
// info.type = "folder";
// // return dirTree(filename);
// // info.children = fs.readdirSync(filename).map(function(child) {
// // return dirTree(path.join(filename,child));
// // });
// } else {
// // Assuming it's a file. In real life it could be a symlink or
// // something else!
// info.type = "file";
// }
// console.log(typeof info);
// console.log(info);
return info;
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Colon",
"version": "1.3.0",
"version": "1.3.1",
"description": "A flexible text editor",
"author": "Harendra Chhekur <820121223505e@gmail.com>",
"main": "main.js",
Expand Down

0 comments on commit 27b53fa

Please sign in to comment.