diff --git a/VERSION b/VERSION index c163047c..b3a2beef 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2012.12.28.01.21.20 +Version 2.4.1-alpha.2+timestamp.2012.12.28.15.44.29 diff --git a/applications/admin/controllers/debug.py b/applications/admin/controllers/debug.py index f02b2866..97ef49f8 100644 --- a/applications/admin/controllers/debug.py +++ b/applications/admin/controllers/debug.py @@ -212,3 +212,26 @@ def toggle_breakpoint(): except Exception, e: session.flash = str(e) return response.json({'ok': ok, 'lineno': lineno}) + +def list_breakpoints(): + "Return a list of linenumbers for current breakpoints" + + breakpoints = [] + ok = None + try: + filename = os.path.join(request.env['applications_parent'], + 'applications', request.vars.filename) + # normalize path name: replace slashes, references, etc... + filename = os.path.normpath(os.path.normcase(filename)) + for bp in qdb_debugger.do_list_breakpoint(): + no, bp_filename, bp_lineno, temporary, enabled, hits, cond = bp + # normalize path name: replace slashes, references, etc... + bp_filename = os.path.normpath(os.path.normcase(bp_filename)) + if filename == bp_filename: + breakpoints.append(bp_lineno) + ok = True + except Exception, e: + session.flash = str(e) + ok = False + return response.json({'ok': ok, 'breakpoints': breakpoints}) + diff --git a/applications/admin/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index b24b2fd0..44d5de7d 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -148,8 +148,12 @@ function getSelectionRange() { return sel; } -function doToggleBreakpoint(filename, url) { - var sel = getSelectionRange(); +function doToggleBreakpoint(filename, url, sel) { + if (sel==null) { + // use cursor position to determine the breakpoint line + // (gutter already tell us the selected line) + sel = getSelectionRange(); + } var dataForPost = prepareMultiPartPOST(new Array( prepareDataForSave('filename', filename), prepareDataForSave('sel_start', sel["start"]), @@ -199,6 +203,43 @@ function doToggleBreakpoint(filename, url) { return false; } +// on load, update all breakpoints markers: +function doListBreakpoints(filename, url) { + var dataForPost = prepareMultiPartPOST(new Array( + prepareDataForSave('filename', filename) + )); + jQuery.ajax({ + type: "POST", + contentType: 'multipart/form-data;boundary="'+dataForPost[1]+'"', + url: url, + dataType: "json", + data: dataForPost[0], + timeout: 5000, + beforeSend: function(xhr) { + xhr.setRequestHeader('web2py-component-location', + document.location); + xhr.setRequestHeader('web2py-component-element', + 'doListBreakpoints');}, + success: function(json,text,xhr){ + try { + if (json.error) { + window.location.href=json.redirect; + } else { + if (window.mirror) { + for (i in json.breakpoints) { + lineno = json.breakpoints[i]; + // mark the breakpoint if ok=True + editor.setMarker(lineno-1, + " %N%"); + } + } + } + } catch(e) { on_error(); } + }, + error: function(json) { on_error(); } + }); + return false; +} function keepalive(url) { jQuery.ajax({ diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index 19c416e4..cb1b6035 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -25,6 +25,13 @@ + {{elif TEXT_EDITOR == 'ace':}} @@ -103,7 +110,7 @@ jQuery(document).ready(function(){ {{if filetype=='python':}} {{=A(SPAN(T('toggle breakpoint')), _value="breakpoint", _name="breakpoint", - _onclick="return doToggleBreakpoint('%s','%s://%s%s');" % (filename, + _onclick="return doToggleBreakpoint('%s','%s://%s%s',null);" % (filename, request.env['wsgi_url_scheme'], request.env['http_host'], URL(c='debug', f='toggle_breakpoint')), _class="button special btn btn-inverse")}} @@ -202,7 +209,13 @@ jQuery(document).ready(function(){ autofocus: true, onCursorActivity: function() { editor.setLineClass(hlLine, null, null); - hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");} + hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");}, + onGutterClick: function(cm, n) { + sel = {start: n, end: n, data: ''}; + doToggleBreakpoint({{=XML("'%s','%s://%s%s',sel" % (filename, + request.env['wsgi_url_scheme'], request.env['http_host'], + URL(c='debug', f='toggle_breakpoint')))}}); + } }; var editor = CodeMirror.fromTextArea( document.getElementById("body"),cm_opts); @@ -293,4 +306,4 @@ window.onload = function() { {{pass}} - \ No newline at end of file +