debugger patch, thanks Mariano
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -212,3 +212,26 @@ def toggle_breakpoint():
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
session.flash = str(e)
|
session.flash = str(e)
|
||||||
return response.json({'ok': ok, 'lineno': lineno})
|
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})
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,12 @@ function getSelectionRange() {
|
|||||||
return sel;
|
return sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doToggleBreakpoint(filename, url) {
|
function doToggleBreakpoint(filename, url, sel) {
|
||||||
var sel = getSelectionRange();
|
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(
|
var dataForPost = prepareMultiPartPOST(new Array(
|
||||||
prepareDataForSave('filename', filename),
|
prepareDataForSave('filename', filename),
|
||||||
prepareDataForSave('sel_start', sel["start"]),
|
prepareDataForSave('sel_start', sel["start"]),
|
||||||
@@ -199,6 +203,43 @@ function doToggleBreakpoint(filename, url) {
|
|||||||
return false;
|
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,
|
||||||
|
"<span style='color: red'>●</span> %N%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) { on_error(); }
|
||||||
|
},
|
||||||
|
error: function(json) { on_error(); }
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function keepalive(url) {
|
function keepalive(url) {
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
|
|||||||
@@ -25,6 +25,13 @@
|
|||||||
<link rel="stylesheet" href="{{=cm}}/lib/util/dialog.css">
|
<link rel="stylesheet" href="{{=cm}}/lib/util/dialog.css">
|
||||||
<script src="{{=cm}}/emmet.min.js"></script>
|
<script src="{{=cm}}/emmet.min.js"></script>
|
||||||
<script language="Javascript" type="text/javascript" src="{{=URL('static','js/ajax_editor.js')}}"></script>
|
<script language="Javascript" type="text/javascript" src="{{=URL('static','js/ajax_editor.js')}}"></script>
|
||||||
|
<script language="Javascript" type="text/javascript">
|
||||||
|
jQuery(document).ready(function(){
|
||||||
|
doListBreakpoints({{=XML("'%s','%s://%s%s'" % (filename,
|
||||||
|
request.env['wsgi_url_scheme'], request.env['http_host'],
|
||||||
|
URL(c='debug', f='list_breakpoints')))}});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{{elif TEXT_EDITOR == 'ace':}}
|
{{elif TEXT_EDITOR == 'ace':}}
|
||||||
<script src="{{=URL(r=request,c='static',f='ace/src/ace.js')}}" type="text/javascript" charset="utf-8"></script>
|
<script src="{{=URL(r=request,c='static',f='ace/src/ace.js')}}" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="{{=URL(r=request,c='static',f='ace/src/theme-%s.js' % TEXT_EDITOR_THEME)}}" type="text/javascript" charset="utf-8"></script>
|
<script src="{{=URL(r=request,c='static',f='ace/src/theme-%s.js' % TEXT_EDITOR_THEME)}}" type="text/javascript" charset="utf-8"></script>
|
||||||
@@ -103,7 +110,7 @@ jQuery(document).ready(function(){
|
|||||||
{{if filetype=='python':}}
|
{{if filetype=='python':}}
|
||||||
{{=A(SPAN(T('toggle breakpoint')),
|
{{=A(SPAN(T('toggle breakpoint')),
|
||||||
_value="breakpoint", _name="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'],
|
request.env['wsgi_url_scheme'], request.env['http_host'],
|
||||||
URL(c='debug', f='toggle_breakpoint')),
|
URL(c='debug', f='toggle_breakpoint')),
|
||||||
_class="button special btn btn-inverse")}}
|
_class="button special btn btn-inverse")}}
|
||||||
@@ -202,7 +209,13 @@ jQuery(document).ready(function(){
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
onCursorActivity: function() {
|
onCursorActivity: function() {
|
||||||
editor.setLineClass(hlLine, null, null);
|
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(
|
var editor = CodeMirror.fromTextArea(
|
||||||
document.getElementById("body"),cm_opts);
|
document.getElementById("body"),cm_opts);
|
||||||
@@ -293,4 +306,4 @@ window.onload = function() {
|
|||||||
{{pass}}
|
{{pass}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- end "edit" block -->
|
<!-- end "edit" block -->
|
||||||
|
|||||||
Reference in New Issue
Block a user