Lines Matching defs:selection

2  * Text selection related functions.
6 * selection prototype
8 * Object that capsulates the selection in a textarea. Returned by DWgetSelection.
29 * Get current selection/cursor position in a given textArea
34 * @returns object - a selection object
48 * Set the selection
50 * You need to get a selection object via DWgetSelection() first, then modify the
55 * @param {selection_class} selection a selection object as returned by DWgetSelection()
57 function DWsetSelection(selection){
58 selection.obj.setSelectionRange(selection.start, selection.end);
59 if(selection.scroll) selection.obj.scrollTop = selection.scroll;
64 * selection
68 * @param {selection_class} selection selection object returned by DWgetSelection
69 * @param {int} opts.startofs number of charcters at the start to skip from new selection
70 * @param {int} opts.endofs number of characters at the end to skip from new selection
73 function pasteText(selection,text,opts){
77 selection.obj.value =
78 selection.obj.value.substring(0, selection.start) + text +
79 selection.obj.value.substring(selection.end, selection.obj.value.length);
81 // set new selection
84 selection.end = selection.start + text.replace(/\r?\n/g, '\r\n').length;
86 selection.end = selection.start + text.length;
90 // modify the new selection if wanted
91 if(opts.startofs) selection.start += opts.startofs;
92 if(opts.endofs) selection.end -= opts.endofs;
94 // no selection wanted? set cursor to end position
95 if(opts.nosel) selection.start = selection.end;
97 DWsetSelection(selection);
102 * Format selection
104 * Apply tagOpen/tagClose to selection in textarea, use sampleText instead
105 * of selection if there is none.
112 var selection = DWgetSelection(txtarea);
113 var text = selection.getText();
116 // don't include trailing space in selection
118 selection.end--;
119 text = selection.getText();
140 pasteText(selection,text,opts);
150 var selection = DWgetSelection(txtarea);
151 pasteText(selection,text,{nosel: true});