Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight multiple selections?

Tags:

ace-editor

For example I have some text in ace-editor and a list of ranges of rows and lines in text where highlightings should happened. Like this (they're bolded):

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam cursus. Morbi ut mi. Nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. Sed eleifend nonummy diam. Praesent mauris ante, elementum et, bibendum at, posuere sit amet, nibh.

How to highlight these words by using ace-editor API?

How to highlight multiple lines?

like image 265
megas Avatar asked Feb 01 '12 04:02

megas


People also ask

How do you highlight multiple selected files?

Click the first file or folder you want to select. Hold down the Shift key, select the last file or folder, and then let go of the Shift key. Hold down the Ctrl key and click any other file(s) or folder(s) you would like to add to those already selected.

How do you highlight multiple things with a mouse?

Click the first item, then press the SHIFT key and hold it. Click the last item and release the SHIFT key. To select adjacent items, you can also use the mouse. Click the left mouse button on the first item, hold the mouse button, move the cursor to the last item and then release the mouse button.

How do you select multiple items in a list?

To select contiguous items in the list, navigate to the first item you want to select, then hold down the SHIFT key and press the DOWN ARROW key until the last item you want to select is highlighted.

How do you highlight multiple sections in Word?

To select multiple areas that aren't next to each other, make your first selection, hold down CTRL, and then select any other items you want.


1 Answers

Finally I've got the answer.

Highlight the word:

var range = new Range(rowStart, columnStart, rowEnd, columnEnd);
var marker = editor.getSession().addMarker(range,"ace_selected_word", "text");

Remove the highlighted word:

editor.getSession().removeMarker(marker);

Highlight the line:

editor.getSession().addMarker(range,"ace_active_line","background");
like image 168
megas Avatar answered Nov 10 '22 10:11

megas