Basic commands and tabs are working.

This commit is contained in:
Thomas Wilburn 2013-08-20 17:35:25 -07:00
parent 2e508a5012
commit f1ba8cee99
6 changed files with 71 additions and 13 deletions

View file

@ -7,9 +7,29 @@ body {
padding: 0;
}
.toolbar {
height: 30px;
width: 100%;
background: blue;
}
.tabs {
height: 30px;
width: 100%;
background: grey;
}
.tabs a {
display: inline-block;
height: 100%;
min-width: 150px;
margin-right: 3px;
background: white;
}
.editor-container {
position: absolute;
top: 0;
top: 60px;
bottom: 0;
left: 0;
right: 0;

View file

@ -26,8 +26,8 @@ define(function() {
};
chrome.fileSystem.chooseEntry({
type: modes[mode]
//acceptsMultiple: false
}, function(entry) {
if (!entry) return;
self.entry = entry;
c(self)
});

View file

@ -1,10 +1,3 @@
require(["editor", "file"], function(editor, File) {
var f = new File();
f.open(function(file) {
f.read(function(err, data) {
editor.getSession().setValue(data);
});
});
require(["sessions"], function() {
});

View file

@ -1,4 +1,4 @@
define(["editor"], function(editor) {
define(["editor", "command", "file"], function(editor, command, File) {
/*
@ -10,5 +10,45 @@ define(["editor"], function(editor) {
- retain file handles after shutdown
*/
var tabs = [];
var current = editor.getSession();
var renderTabs = function() {
var tabContainer = document.querySelector(".tabs");
var contents = "";
tabs.forEach(function(tab, index) {
contents += "<a command='session:raise-tab' argument='" + index + "'>" + index + "</a>";
});
tabContainer.innerHTML = contents;
}
var addTab = function() {
var session = ace.createEditSession("", "ace/mode/text");
tabs.push(session);
current = session;
renderTabs();
return session;
};
var raiseTab = function(index) {
var tab = tabs[index];
editor.setSession(tab);
}
var openFile = function() {
var f = new File();
f.open(function(file) {
f.read(function(err, data) {
var session = addTab();
session.setValue(data);
editor.setSession(session);
});
});
}
command.on("session:open-file", openFile);
command.on("session:raise-tab", raiseTab);
});

View file

@ -6,6 +6,11 @@
</head>
<body>
<div class="toolbar">
<button command="session:open-file">OPEN</button>
</div>
<div class="tabs"></div>
<div class="editor-container">
<div id="editor"></div>
</div>

View file

@ -1,6 +1,6 @@
{
"name": "ChromeEdit",
"description": "Lightweight text editing for Chrome",
"name": "Caret",
"description": "Sublime text editing for Chrome",
"version": "0.0.0",
"manifest_version": 2,