bsdz wrote:
> Hi,
> 
> I dabbled a little with the vmware version of Sage and was able to
> install EditArea, a javascript syntax highlighting library (http://
> www.cdolivet.net/index.php?page=editArea). It is quite useful when
> editing Python and can be turned on or off. It also allows callbacks
> so pressing the save button can run evaluate_cell. It might be an
> alternative to using the It's All Text Firefox plug-in.
> 
> The installation is very easy.
> 
> 1) Install the EditArea library under /usr/local/sage/data/extcode/
> notebook/javascript.
> 
> 2) Edit /usr/local/sage/devel/sage-main/build/sage/server/notebook/
> notebook.py and add the line: -
> 
>             head += '\n<script type="text/javascript" src="/javascript/
> editarea/edit_area/edit_area_full.js"></script>\n'
> 
> after
> 
>             head += '\n<script type="text/javascript" src="/javascript/
> main.js"></script>\n'
> 
> in function _html_head.
> 
> 3) Edit /usr/local/sage/devel/sage-main/build/sage/server/notebook/
> cell.py and add the lines: -
> 
>             s += """
>             <script language="Javascript" type="text/javascript">
>               editAreaLoader.init({
>               id: "cell_input_%s"
>               ,start_highlight: true
>               ,allow_resize: "y"
>               ,allow_toggle: true
>               ,language: "en"
>               ,syntax: "python"
>               ,save_callback: "evaluate_cell('%s', false)"
>               ,toolbar: "save,|, search, go_to_line, |, undo, redo, |,
> select_font, |, change_smooth_selection, highlight, reset_highlight,
> |, help"
>               ,replace_tab_by_spaces: 4
>               ,min_height: 350
>               ,show_line_colors: true
>             });
>             </script>
>             """%(id, id)
> 
> after
> 
>             s += """
>                <textarea class="%s" rows=%s cols=%s
>                   id         = 'cell_input_%s'
>                   onKeyPress = 'return input_keypress(%s,event);'
>                   onKeyDown  = 'return input_keydown(%s,event);'
>                   onKeyUp    = 'return input_keyup(%s, event);'
>                   onBlur     = 'cell_blur(%s); return true;'
>                   onFocus    = 'cell_focused(this,%s); return true;'
>                >%s</textarea>
>             """%(cls, r, ncols, id, id, id, id, id, id, t)
> 
> in the function html_in.
> 
> 4) Restart the notebook server.


This does look interesting.  One possible problem I see is that I tried 
a similar thing with TinyMCE and ran into problems on Safari.  It seemed 
that Safari doesn't automatically evaluate <script> tags when they are 
inserted into the DOM, like Firefox does, so I had to change the 
client-side javascript to specifically execute them.  The changes are in 
safari-fix.patch at http://trac.sagemath.org/sage_trac/ticket/4705.

I can't test the above in Safari, so I'm not sure that the above code 
will run into this problem, though.

Thanks,

Jason


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to