Modify the Ajax.org Cloud9 Editor Gutter (Ace Editor)

I have an Ace editor built into my website in which I allow users to enter it. Currently, the inline function automatically shows the line number for each line inserted as follows:

Line number automatically inserted

Is there a way to set the contents in the gutter manually and read the value in it later?
For example: instead of setting it to 1,2,3 ... I would like it to look like

A abc
B def

And then, when I access the line containing "abc", I would like to read the value in the chute of this line, which is equal to "A".

Update:

To configure the gutter for the Ace editor, you will have to override the "update" function:

ace.require("ace/layer/my_gutter")
//...

define('ace/layer/my_gutter', ['require', 'exports', 'ace/lib/dom'], function(require, exports, module) {

    var dom = require("ace/lib/dom"); 
    require("ace/layer/gutter").Gutter.prototype.update = update = 
        function(config) { 
            //...
        }; 
});

, . , .

, CodeMirror, CodeMirror.

+4
1

editor.session.gutterRenderer =  {
    getWidth: function(session, lastLineNumber, config) {
        return lastLineNumber.toString().length * config.characterWidth;
    },
    getText: function(session, row) {
        return String.fromCharCode(row + 65);
    }
};
+6

All Articles