Yeah I know is little old style, but maybe usefull if you want to make a block comment label into your code, like this:
<!--
*******************************************
* SCRIPTS *
*******************************************
-->
or
/*
************************************************
* MY BEAUTIFUL CLASS *
************************************************
*/
CODE
doc = komodo.view;
ide = require( "ko/editor" );
view = require("ko/views").current();
require( "ko/modal" ).open({
title: "Comment Block Maker",
fields: {
fieldName1: {
label: "Width ",
type: "textbox",
value: "48"
},
fieldName2: {
label: "Title ",
type: "textbox",
value: "TITLE"
}
},
onComplete: function(elem) {
lineNumber = ide.getSelectionRange("relative").end.line;
indent = ide.getLine(lineNumber).replace(/(^\s*\s).*/mg, "$1");
lang = view.get('language');
eolSet = view.koDoc.new_line_endings;
if (eolSet === 1){ eol = '\r';}
if (eolSet === 2){ eol = '\r\n';}
if (eolSet === 3){ eol = '\n';}
if (lang == 'HTML' || lang == 'HTML5'){
commentStart = '<!--';
commentEnd = '-->';
}else{
commentStart = '/*';
commentEnd = ' */';
}
asterisk = '*';
left = Math.round( ( (elem.fieldName1 * 1) - elem.fieldName2.length - 1 ) / 2 ) ;
right = (elem.fieldName1 * 1) - left - elem.fieldName2.length - 2;
if (elem.fieldName1 && elem.fieldName2) {
template =
//////////////////////////////////////////////
`${commentStart}${eol}${indent} ${asterisk.repeat(elem.fieldName1 *1)}${eol}${indent} ${asterisk}${' '.repeat(left)}${elem.fieldName2}${' '.repeat(right)}${asterisk}${eol}${indent} ${asterisk.repeat(elem.fieldName1 *1)}${eol}${indent}${commentEnd}${eol}`;
//////////////////////////////////////////////
doc.selection = template;
return;
}
},
okLabel: "Yes",
cancelLabel: "No"
});