Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Commit

Permalink
Added inline annotation support for language extensions, used by the
Browse files Browse the repository at this point in the history
  • Loading branch information
zefhemel committed Jan 20, 2014
1 parent b73a2ea commit 59ae66c
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 6 deletions.
4 changes: 1 addition & 3 deletions app/config/default/command/snippet_completer.js
@@ -1,8 +1,6 @@
/* global _ */
/* global _, define */
define(function(require, exports, module) {
var session = require("zed/session");
return function(info, callback) {
var path = info.path;
var snippets = info.snippets;
callback(null, _.map(snippets, function(snippet, name) {
return {
Expand Down
1 change: 1 addition & 0 deletions app/config/default/mode/javascript/check.js
Expand Up @@ -120,6 +120,7 @@ define(function(require, exports, module) {
errors.push({
row: error.line - 1,
column: error.character - 1,

text: error.reason,
type: type,
raw: raw
Expand Down
2 changes: 1 addition & 1 deletion app/config/default/mode/javascript/jshint.js
Expand Up @@ -1031,7 +1031,7 @@ exports.register = function (linter) {
data: [ data.value ]
});
}

if (data.value.substr(data.value.length - 1) === ".") {
// Warn about a trailing decimal point.
linter.warn("W047", {
Expand Down
16 changes: 16 additions & 0 deletions app/css/editor.css
Expand Up @@ -353,4 +353,20 @@ body.non_mac ::-webkit-scrollbar-thumb:horizontal {
}
body.non_mac ::-webkit-scrollbar-thumb:hover {
-webkit-box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.9), inset 0 0 0 4px rgba(128, 128, 128, 0.9);
}
/* Markers */
.marker-highlight-warning {
position: absolute;
border-bottom: solid 1px #CCCC00;
z-index: 1000;
}
.marker-highlight-error {
position: absolute;
border-bottom: solid 1px red;
z-index: 1000;
}
.marker-highlight-info {
position: absolute;
border-bottom: solid 1px blue;
z-index: 1000;
}
2 changes: 2 additions & 0 deletions app/js/boot.js
Expand Up @@ -49,6 +49,8 @@ require(["text!../manual/cheatsheet.md"], function(cheatsheet) {
_.each(arguments, function(module) {
if (module.hook) module.hook();
});


_.each(arguments, function(module) {
if (module.init) module.init();
});
Expand Down
1 change: 0 additions & 1 deletion app/js/editor.js
Expand Up @@ -905,5 +905,4 @@ define(function(require, exports, module) {
});
});


});
35 changes: 35 additions & 0 deletions app/js/lib/inline_annotation.js
@@ -0,0 +1,35 @@
/* global ace, define*/
define(function(require, exports, module) {
var Anchor = ace.require("ace/anchor").Anchor;
var Range = ace.require("ace/range").Range;

function InlineAnnotation(session, info) {
this.session = session;
this.info = info;
this.startAnchor = new Anchor(session.getDocument(), info.row, info.column);
this.endAnchor = new Anchor(session.getDocument(), info.row, info.endColumn);
this.startAnchor.on("change", this.update.bind(this));
this.endAnchor.on("change", this.update.bind(this));
this.marker = null;
this.update();
}

InlineAnnotation.prototype = {
update: function() {
var range = Range.fromPoints(this.startAnchor.getPosition(), this.endAnchor.getPosition());
if (this.marker) {
this.session.removeMarker(this.marker);
}
this.marker = this.session.addMarker(range, "marker-highlight-" + this.info.type);
},
remove: function() {
this.startAnchor.detach();
this.endAnchor.detach();
if (this.marker) {
this.session.removeMarker(this.marker);
}
}
};

return InlineAnnotation;
});
16 changes: 15 additions & 1 deletion app/js/sandbox/impl/zed/session.js
Expand Up @@ -2,6 +2,7 @@ define(function(require, exports, module) {
var session_manager = require("../../../session_manager");
var Range = ace.require("ace/range").Range;
var editor = require("../../../editor");
var InlineAnnotation = require("../../../lib/inline_annotation");

function rangify(range) {
return Range.fromPoints(range.start, range.end);
Expand All @@ -22,7 +23,20 @@ define(function(require, exports, module) {
});
},
setAnnotations: function(path, annos, callback) {
getSession(path).setAnnotations(annos);
var session = getSession(path);
(session.annotations || []).forEach(function(anno) {
console.log("Removing anno", anno);
anno.remove();
});
session.annotations = [];
for(var i = 0; i < annos.length; i++) {
var anno = annos[i];
// If no endColum, no inline marker is required
if(anno.endColumn) {
session.annotations.push(new InlineAnnotation(session, anno));
}
}
session.setAnnotations(annos);
callback();
},
getText: function(path, callback) {
Expand Down
16 changes: 16 additions & 0 deletions app/manual/projects.md
@@ -0,0 +1,16 @@
Zed Projects
============

Zed is an editor based on projects. When you do a fresh Zed install, a few project-like options will be available, including "Open Local Folder", "Open Dropbox Folder", "Notes", "Configuration", and "Manual".

Editing Local Files
-------------------
To edit the files in a folder on your local hard drive pick "Open Local Folder". A new Zed window will open allowing you to select the folder to edit. After you switch back to the Zed Project Picker window, you will see that the folder you just opened has been added to your project list.

Editing Files on Dropbox
------------------------
To edit files on Dropbox, select "Open Dropbox Folder", login with Dropbox and select the folder to edit. After you opened the folder and switching back to the Project Picker, you'll notice that the folder you just openened has been added to your project list.

Notes
-----
Notes is a special built-in project that stores its files on Google Drive

0 comments on commit 59ae66c

Please sign in to comment.