Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Half-solution to `gotoLine` working intermittently.

  • Loading branch information...
commit bff3d673fc3f7c1c18439c237a61a0fe27cab87e 1 parent ff22571
@mauricemach authored
Showing with 21 additions and 15 deletions.
  1. +9 −7 index.coffee
  2. +12 −8 index.html
View
16 index.coffee
@@ -48,8 +48,8 @@ template = ->
try
options = format: $('#format').is(':checked'), autoescape: yes
eval 'opts = ' + $('#opts').val()
- out.getSession().setValue(CoffeeKup.render(editor.getSession().getValue(), opts, options))
- out.gotoLine 1
+ out_session.setValue(CoffeeKup.render(editor_session.getValue(), opts, options))
+ setTimeout (-> out.gotoLine 1), 100
$('#errors').hide()
catch err
$('#errors').show().html err.message
@@ -60,23 +60,25 @@ template = ->
$('#opts').val "{title: 'Foo', path: '/zig', user: {}, max: 12, locals: {shoutify: function(s){return s.toUpperCase() + \'!\';}}}"
editor = ace.edit 'in'
+ editor_session = editor.getSession()
out = ace.edit 'out'
+ out_session = out.getSession()
CoffeeMode = require("ace/mode/coffee").Mode
- editor.getSession().setMode(new CoffeeMode())
+ editor_session.setMode(new CoffeeMode())
HtmlMode = require("ace/mode/html").Mode
- out.getSession().setMode(new HtmlMode())
+ out_session.setMode(new HtmlMode())
editor.setTheme("ace/theme/twilight")
out.setTheme("ace/theme/twilight")
- editor.getSession().setTabSize 2
- editor.getSession().setUseSoftTabs on
+ editor_session.setTabSize 2
+ editor_session.setUseSoftTabs on
out.setReadOnly on
$('.ace_gutter').css('background-color', '#2a211c').css('color', '#555')
- editor.getSession().on 'change', -> compile()
+ editor_session.on 'change', -> compile()
compile()
View
20 index.html
@@ -1,6 +1,6 @@
<!DOCTYPE html><html><head><meta charset="utf-8" /><title>CoffeeKup</title><script src="jquery-1.6.2.min.js"></script><script src="ace-0.1.6/src/ace.js"></script><script src="ace-0.1.6/src/mode-coffee.js"></script><script src="ace-0.1.6/src/mode-html.js"></script><script src="ace-0.1.6/src/theme-twilight.js"></script><script src="coffee-script.js"></script><script src="coffeekup.js"></script><script>(function () {
return $(function() {
- var CoffeeMode, HtmlMode, compile, editor, out;
+ var CoffeeMode, HtmlMode, compile, editor, editor_session, out, out_session;
compile = function() {
var options;
try {
@@ -9,8 +9,10 @@
autoescape: true
};
eval('opts = ' + $('#opts').val());
- out.getSession().setValue(CoffeeKup.render(editor.getSession().getValue(), opts, options));
- out.gotoLine(1);
+ out_session.setValue(CoffeeKup.render(editor_session.getValue(), opts, options));
+ setTimeout((function() {
+ return out.gotoLine(1);
+ }), 100);
return $('#errors').hide();
} catch (err) {
return $('#errors').show().html(err.message);
@@ -24,18 +26,20 @@
});
$('#opts').val("{title: 'Foo', path: '/zig', user: {}, max: 12, locals: {shoutify: function(s){return s.toUpperCase() + \'!\';}}}");
editor = ace.edit('in');
+ editor_session = editor.getSession();
out = ace.edit('out');
+ out_session = out.getSession();
CoffeeMode = require("ace/mode/coffee").Mode;
- editor.getSession().setMode(new CoffeeMode());
+ editor_session.setMode(new CoffeeMode());
HtmlMode = require("ace/mode/html").Mode;
- out.getSession().setMode(new HtmlMode());
+ out_session.setMode(new HtmlMode());
editor.setTheme("ace/theme/twilight");
out.setTheme("ace/theme/twilight");
- editor.getSession().setTabSize(2);
- editor.getSession().setUseSoftTabs(true);
+ editor_session.setTabSize(2);
+ editor_session.setUseSoftTabs(true);
out.setReadOnly(true);
$('.ace_gutter').css('background-color', '#2a211c').css('color', '#555');
- editor.getSession().on('change', function() {
+ editor_session.on('change', function() {
return compile();
});
return compile();
Please sign in to comment.
Something went wrong with that request. Please try again.