mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
alt-t adjust tab at point
This commit is contained in:
parent
efc3b51ef0
commit
44c9497ed1
3 changed files with 64 additions and 8 deletions
|
|
@ -81,6 +81,36 @@
|
||||||
~A.trigger('clog-save-ace');
|
~A.trigger('clog-save-ace');
|
||||||
},
|
},
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
});"
|
||||||
|
(clog-ace::js-ace editor)
|
||||||
|
(jquery editor)))
|
||||||
|
;; setup adjust tab key
|
||||||
|
(js-execute editor
|
||||||
|
(format nil
|
||||||
|
"~A.commands.addCommand({
|
||||||
|
name: 'adjust-tabs',
|
||||||
|
bindKey: {win: 'Alt-t', mac: 'Command-t'},
|
||||||
|
exec: function(editor) {
|
||||||
|
var row = editor.selection.getCursor().row;
|
||||||
|
var column = editor.selection.getCursor().column;
|
||||||
|
var c;
|
||||||
|
var sr=row;
|
||||||
|
var bp=0;
|
||||||
|
row--;
|
||||||
|
column=500;
|
||||||
|
while (row > 0) {
|
||||||
|
c=editor.session.getTextRange(new ace.Range(row, column-1, row, column));
|
||||||
|
if (c==')') { bp++; }
|
||||||
|
if (c=='(') { bp--; }
|
||||||
|
if (bp < 0) { break; }
|
||||||
|
column--;
|
||||||
|
if (column < 0) { row--; column=500;}
|
||||||
|
}
|
||||||
|
c = editor.session.getTextRange(new ace.Range(row, 0, sr, 500));
|
||||||
|
editor.session.selection.setSelectionRange(new ace.Range(sr, 0, sr, 500));
|
||||||
|
~A.trigger('clog-adjust-tabs',c);
|
||||||
|
},
|
||||||
|
readOnly: true,
|
||||||
});"
|
});"
|
||||||
(clog-ace::js-ace editor)
|
(clog-ace::js-ace editor)
|
||||||
(jquery editor)))
|
(jquery editor)))
|
||||||
|
|
@ -154,7 +184,7 @@
|
||||||
(format nil
|
(format nil
|
||||||
"~A.commands.addCommand({
|
"~A.commands.addCommand({
|
||||||
name: 'expand-region',
|
name: 'expand-region',
|
||||||
bindKey: {win: 'Ctrl-=', mac: 'Control-='},
|
bindKey: {win: 'Alt-=', mac: 'Control-='},
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
var currentRange = editor.selection.getAllRanges()[0];
|
var currentRange = editor.selection.getAllRanges()[0];
|
||||||
var start = editor.session.doc.positionToIndex(currentRange.start);
|
var start = editor.session.doc.positionToIndex(currentRange.start);
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ provide an interactive console.)"))
|
||||||
(with-open-stream (in-stream (make-instance 'dialog-in-stream :clog-obj clog-obj :source out-stream))
|
(with-open-stream (in-stream (make-instance 'dialog-in-stream :clog-obj clog-obj :source out-stream))
|
||||||
(labels ((reset-ace ()
|
(labels ((reset-ace ()
|
||||||
(when (typep console 'console-out-stream)
|
(when (typep console 'console-out-stream)
|
||||||
(setf (clog-ace:mode (ace console)) "ace/mode/lisp")
|
|
||||||
(setf (ace console) nil)))
|
(setf (ace console) nil)))
|
||||||
(my-debugger (condition encapsulation)
|
(my-debugger (condition encapsulation)
|
||||||
(if clog-obj
|
(if clog-obj
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@
|
||||||
(m-load (create-gui-menu-item m-file :content "load"))
|
(m-load (create-gui-menu-item m-file :content "load"))
|
||||||
(m-save (create-gui-menu-item m-file :content "save (cmd/ctrl-s)"))
|
(m-save (create-gui-menu-item m-file :content "save (cmd/ctrl-s)"))
|
||||||
(m-saveas (create-gui-menu-item m-file :content "save as.."))
|
(m-saveas (create-gui-menu-item m-file :content "save as.."))
|
||||||
|
(m-revert (create-gui-menu-item m-file :content "revert"))
|
||||||
(m-emacs (unless (in-clog-popup-p obj)
|
(m-emacs (unless (in-clog-popup-p obj)
|
||||||
(create-gui-menu-item m-file :content "open in emacs")))
|
(create-gui-menu-item m-file :content "open in emacs")))
|
||||||
(m-ntab (unless (in-clog-popup-p obj)
|
(m-ntab (unless (in-clog-popup-p obj)
|
||||||
|
|
@ -215,13 +216,14 @@
|
||||||
"<table>
|
"<table>
|
||||||
<tr><td>cmd/ctrl-,</td><td>Configure editor</td></tr>
|
<tr><td>cmd/ctrl-,</td><td>Configure editor</td></tr>
|
||||||
<tr><td>F1</td><td>Command Palette</td></tr>
|
<tr><td>F1</td><td>Command Palette</td></tr>
|
||||||
<tr><td>cmd/alt-.</td><td> Launch system browser</td></tr>
|
<tr><td>cmd/alt-.</td><td>Launch system browser</td></tr>
|
||||||
<tr><td>cmd/alt-[</td><td> Evaluate form</td></tr>
|
<tr><td>cmd/alt-[</td><td>Evaluate form</td></tr>
|
||||||
<tr><td>cmd/ctrl-s</td><td> Save</td></tr>
|
<tr><td>cmd/ctrl-s</td><td>Save</td></tr>
|
||||||
<tr><td>ctl-=</td><td>Expand region</td></tr>
|
<tr><td>cmd/alt-t</td><td>Adjust tabs at cursor</td></tr>
|
||||||
|
<tr><td>ctl/alt-=</td><td>Expand region</td></tr>
|
||||||
<tr><td>opt/alt-m</td><td>Macroexpand</td></tr>
|
<tr><td>opt/alt-m</td><td>Macroexpand</td></tr>
|
||||||
</table><p><a target='_blank' href='https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts'>Default Keybindings</a>"
|
</table><p><a target='_blank' href='https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts'>Default Keybindings</a>"
|
||||||
:width 400 :height 350
|
:width 400 :height 400
|
||||||
:title "Help")))
|
:title "Help")))
|
||||||
(set-on-click btn-help #'on-help)
|
(set-on-click btn-help #'on-help)
|
||||||
(set-on-click m-helpk #'on-help))
|
(set-on-click m-helpk #'on-help))
|
||||||
|
|
@ -267,7 +269,11 @@
|
||||||
(js-execute obj (format nil "~A.find('~A',{caseSensitive:false,regExp:true})"
|
(js-execute obj (format nil "~A.find('~A',{caseSensitive:false,regExp:true})"
|
||||||
(clog-ace::js-ace ace) regex)))
|
(clog-ace::js-ace ace) regex)))
|
||||||
(set-on-click btn-load (lambda (obj) (load-file obj)))
|
(set-on-click btn-load (lambda (obj) (load-file obj)))
|
||||||
(set-on-click m-load (lambda (obj) (load-file obj))))
|
(set-on-click m-load (lambda (obj) (load-file obj)))
|
||||||
|
(set-on-click m-revert (lambda (obj)
|
||||||
|
(declare (ignore obj))
|
||||||
|
(setf is-dirty nil)
|
||||||
|
(open-file-name file-name))))
|
||||||
(set-on-input ace (lambda (obj)
|
(set-on-input ace (lambda (obj)
|
||||||
(declare (ignore obj))
|
(declare (ignore obj))
|
||||||
(setf is-dirty t)))
|
(setf is-dirty t)))
|
||||||
|
|
@ -451,6 +457,27 @@
|
||||||
(clog-ace::js-ace ace)
|
(clog-ace::js-ace ace)
|
||||||
(escape-string r)))
|
(escape-string r)))
|
||||||
(setf is-dirty t))))
|
(setf is-dirty t))))
|
||||||
|
(set-on-event-with-data ace "clog-adjust-tabs"
|
||||||
|
(lambda (obj data)
|
||||||
|
(declare (ignore obj))
|
||||||
|
(let ((r (make-array '(0) :element-type 'base-char
|
||||||
|
:fill-pointer 0 :adjustable t)))
|
||||||
|
(with-output-to-string (s r)
|
||||||
|
(with-input-from-string (n data)
|
||||||
|
(let ((*standard-output* s))
|
||||||
|
(indentify:indentify n))))
|
||||||
|
(loop
|
||||||
|
(multiple-value-bind (start end)
|
||||||
|
(ppcre:scan "(^.*)\\n" r)
|
||||||
|
(unless start
|
||||||
|
(return))
|
||||||
|
(setf r (subseq r end))))
|
||||||
|
(unless (or (eq r nil)
|
||||||
|
(equal r ""))
|
||||||
|
(js-execute ace (format nil "~A.insert('~A',true)"
|
||||||
|
(clog-ace::js-ace ace)
|
||||||
|
(escape-string r)))
|
||||||
|
(setf is-dirty t)))))
|
||||||
(labels ((eval-form (obj)
|
(labels ((eval-form (obj)
|
||||||
(let ((p (parse-integer
|
(let ((p (parse-integer
|
||||||
(js-query obj
|
(js-query obj
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue