100
QString getCurrentSymbol (const QString &context_line, int cursor_pos, bool strict) {
101
if (context_line.isEmpty ()) return (QString ());
103
int current_word_start;
104
int current_word_end;
105
getCurrentSymbolOffset (context_line, cursor_pos, strict, ¤t_word_start, ¤t_word_end);
107
// if both return the same position, we're on a non-word.
108
if (current_word_start == current_word_end) return (QString ());
110
return (context_line.mid (current_word_start, current_word_end - current_word_start));
113
void getCurrentSymbolOffset (const QString &context_line, int cursor_pos, bool strict, int *start, int *end) {
114
if (context_line.isEmpty ()) {
120
// step 1: find out word under cursor
121
// We want to match any valid R name, that is, everything composed of letters, 0-9, '.'s and '_'s..
124
rx_no_word = QRegExp ("[^A-Za-z0-9\\._]");
126
rx_no_word = QRegExp ("[^A-Za-z0-9\\._\\$\\:\\[\"\\]]");
129
// find out the next non-word stuff left and right of the current cursor position
130
*start = context_line.findRev (rx_no_word, cursor_pos-1) + 1;
131
*end = context_line.find (rx_no_word, cursor_pos);
132
if (*end < 0) *end = context_line.length ();