Skip to content

Commit

Permalink
added interpreter level formatting option
Browse files Browse the repository at this point in the history
  • Loading branch information
flouc001 committed Mar 2, 2017
1 parent 1a453b1 commit 0eda47c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
<p><label><input id=code_aim type=checkbox>in <u>m</u>ethods:</label> <label><input id=code_swm size=1> spaces</label>
<p><label><input id=code_icom type=checkbox><u>I</u>ndent lines that contain only a comment</label>
<p><label><input id=code_io type=checkbox>I<u>n</u>dent content when an editor is opened</label>
<p><label><input id=code_ilf type=checkbox>Handle <u>f</u>ormatting through the interpreter</label>
<p><label><input id=code_mb type=checkbox><u>H</u>ighlight matching brackets: <tt>()[]{}</tt></label></p>
<p><label><input id=code_acbr type=checkbox>Au<u>t</u>o-close brackets</label>
<p><label><input id=code_acbl type=checkbox>Auto-c<u>l</u>ose blocks: <tt>:If :For ...</tt></label>
Expand Down
12 changes: 10 additions & 2 deletions src/ed.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,16 @@ D.Ed.prototype={
}
this.tc&&D.send('SetLineAttributes',{win:this.id,stop:this.getStops()})
},
RD:function(cm){if(cm.somethingSelected()){cm.execCommand('indentAuto')}
else{var u=cm.getCursor();cm.execCommand('SA');cm.execCommand('indentAuto');cm.setCursor(u)}},
RD:function(cm){
if (D.prf.ilf()){
var cm_v=this.cm.getValue().split('\n')
D.send('FormatCode',{win:this.id,text:cm_v})
}
else{
if(cm.somethingSelected()){cm.execCommand('indentAuto')}
else{var u=cm.getCursor();cm.execCommand('SA');cm.execCommand('indentAuto');cm.setCursor(u)}
}
},
VAL:function(cm){var a=cm.getSelections(), s=a.length!==1?'':!a[0]?this.cword():a[0].indexOf('\n')<0?a[0]:''
s&&this.ide.exec([' '+s],0)},
addJump:function(){var j=this.jumps,u=this.cm.getCursor();j.push({lh:this.cm.getLineHandle(u.line),ch:u.ch})>10&&j.shift()},
Expand Down
4 changes: 4 additions & 0 deletions src/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ D.IDE=function(){'use strict'
},
ReplyGetSIStack:function(x){ide.sis&&ide.sis.render(x.stack)},
ReplyGetThreads:function(x){ide.stp&&ide.stp.render(x.threads)},
ReplyFormatCode:function(x){
var w=D.wins[x.win]
w.cm.setValue(x.text.join('\n'))
},
ReplyTreeList:function(x){ide.wse.replyTreeList(x)},
StatusOutput:function(x){
var w=ide.wStatus;if(!D.el)return
Expand Down
1 change: 1 addition & 0 deletions src/prf.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ D.prf={}
['lbarOrder', D.lb.order],
['lineNums', 1],
['matchBrackets', 1], //whether to highlight matching brackets
['ilf', 1], //when re-formating use ODE style (interpreter level formatting)
['otherExe', ''],//content of the "exe" text box "Other..." is selected in the Connect page
['prefixKey', '`'],
['prefixMaps', {}],//per-locale strings of pairs of characters - diffs from the default map for that locale
Expand Down
1 change: 1 addition & 0 deletions src/prf_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ D.prf_tabs.code={
var swm=p.indentMethods();q.aim.checked=swm>=0;q.swm.value=swm<0&&2||swm
q.icom.checked=!!p.indentComments ()
q.io .checked=!!p.indentOnOpen ()
q.ilf .checked=!!p.ilf ()
q.mb .checked=!!p.matchBrackets ()
q.acbr.checked=!!p.autoCloseBrackets ()
q.acbl.checked=!!p.autoCloseBlocks ()
Expand Down

1 comment on commit 0eda47c

@flouc001
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #68

Please sign in to comment.