1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-14 03:53:59 +02:00

Fix editor options

Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
Marco Dickert
2020-06-08 17:03:31 +02:00
parent f74856f346
commit 6b201aec3f
2 changed files with 29 additions and 23 deletions

View File

@@ -484,7 +484,7 @@ function IFM(params) {
// $(ihatethisfuckingpopoverworkaround.tip).find( '.popover-body' ).empty(); // $(ihatethisfuckingpopoverworkaround.tip).find( '.popover-body' ).empty();
var aceSession = self.editor.getSession(); var aceSession = self.editor.getSession();
var content = self.getNodesFromString( var content = self.getNodeFromString(
Mustache.render( Mustache.render(
self.templates.file_editoroptions, self.templates.file_editoroptions,
{ {
@@ -499,28 +499,32 @@ function IFM(params) {
} }
) )
); );
content.forEach( function( el ) { if( el = content.querySelector("#editor-wordwrap" )) {
if( el.id == "editor-wordwrap" ) el.addEventListener( 'change', function( e ) {
el.addEventListener( 'change', function( e ) { aceSession.setOption( 'wrap', e.srcElement.checked );
self.editor.setOption( 'wrap', e.srcElement.checked ); });
}); }
else if( el.id == "editor-softtabs" ) if( el = content.querySelector("#editor-softtabs" ))
el.addEventListener( 'change', function( e ) { el.addEventListener( 'change', function( e ) {
self.editor.setOption( 'useSoftTabs', e.srcElement.checked ); aceSession.setOption( 'useSoftTabs', e.srcElement.checked );
}); });
else if( el.lastChild && el.lastChild.id == "editor-tabsize" ) if( el = content.querySelector("#editor-tabsize" )) {
el.lastChild.addEventListener( 'keydown', function( e ) { console.log("Found tabSize");
if( e.key == 'Enter' ) { el.addEventListener( 'keydown', function( e ) {
e.preventDefault(); console.log("Got keydown");
self.editor.setOption( 'tabSize', e.srcElement.value ); console.log("Set tabsize to "+e.srcElement.value);
} if( e.key == 'Enter' ) {
}); console.log("Saw ENTER key");
else if( el.id == "editor-syntax" ) e.preventDefault();
el.addEventListener( 'change', function( e ) { aceSession.setOption( 'tabSize', e.srcElement.value );
self.editor.getSession().setMode( e.target.value ); }
}); });
}); }
return $(content); if( el = content.querySelector("#editor-syntax" ))
el.addEventListener( 'change', function( e ) {
aceSession.getSession().setMode( e.target.value );
});
return content;
} }
}); });

View File

@@ -1,3 +1,4 @@
<div>
<div class="form-check p-0"> <div class="form-check p-0">
<input type="checkbox" id="editor-wordwrap" <input type="checkbox" id="editor-wordwrap"
{{#wordwrap}} {{#wordwrap}}
@@ -23,3 +24,4 @@
{{/modes}} {{/modes}}
</select> </select>
{{/ace_includes}} {{/ace_includes}}
</div>