On Sun, Jun 21, 2009 at 12:47 AM, Pat LeSmithe<qed...@gmail.com> wrote: > > William Stein wrote: >> What about control-enter? Can you make it so >> control-enter = linebreak >> shift-enter = submit >> ? > > Control-enter is bound to spliteval_cell. To make control-shift-enter, > say, insert a line break, try augmenting notebook.py's tinyMCE.init()'s > setup with some code ripped from the Safari plug-in: > > // Around line 1840 of sage/server/notebook/notebook.py > setup : function(ed) { > ed.onKeyDown.add(function(ed, e) { > // Make ctrl-shift-enter insert a line break. Copied from > the Safari plug-in. > if (e.keyCode == 13 && e.shiftKey && e.ctrlKey) { > // Workaround for missing shift+enter support, > http://bugs.webkit.org/show_bug.cgi?id=16973 > var dom = ed.dom, s = ed.selection, r = s.getRng(), br; > > // Insert BR element > r.insertNode(br = dom.create('br')); > > // Place caret after BR > r.setStartAfter(br); > r.setEndAfter(br); > s.setRng(r); > > // Could not place caret after BR then insert an nbsp > entity and move the caret > if (s.getSel().focusNode == br.previousSibling) { > > s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'), br)); > s.collapse(1); > } > > // Scroll to new position, scrollIntoView can't be > used due to bug: http://bugs.webkit.org/show_bug.cgi?id=16117 > ed.getWin().scrollTo(0, > dom.getPos(s.getRng().startContainer).y); > > tinymce.dom.Event.cancel(e); > } > }); > // Make shift-enter quit editing. This is the "old" code. > ed.onKeyDown.add(function(ed, e) { > if (key_enter_shift(key_event(e))) { > $(ed.formElement).submit(); > } > }) > } > > This seems to work on Linux in Firefox, Opera, and the Qt 4.5 WebKit > demo browser (e.g., /usr/lib64/qt4/demos/browser/browser).
Thanks! This is now http://sagetrac.org/sage_trac/ticket/6459 William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---