Changeset View
Changeset View
Standalone View
Standalone View
src/script/katescriptdocument.cpp
Context not available. | |||||
52 | return m_document->defStyleNum(line, column); | 52 | return m_document->defStyleNum(line, column); | ||
---|---|---|---|---|---|
53 | } | 53 | } | ||
54 | 54 | | |||
55 | int KateScriptDocument::defStyleNum(const KTextEditor::Cursor &cursor) | | |||
56 | { | | |||
57 | return defStyleNum(cursor.line(), cursor.column()); | | |||
58 | } | | |||
59 | | ||||
60 | int KateScriptDocument::defStyleNum(const QJSValue &jscursor) | 55 | int KateScriptDocument::defStyleNum(const QJSValue &jscursor) | ||
61 | { | 56 | { | ||
62 | return defStyleNum(cursorFromScriptValue(jscursor)); | 57 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
58 | return defStyleNum(cursor.line(), cursor.column()); | ||||
63 | } | 59 | } | ||
64 | 60 | | |||
65 | bool KateScriptDocument::isCode(int line, int column) | 61 | bool KateScriptDocument::isCode(int line, int column) | ||
Context not available. | |||||
68 | return _isCode(defaultStyle); | 64 | return _isCode(defaultStyle); | ||
69 | } | 65 | } | ||
70 | 66 | | |||
71 | bool KateScriptDocument::isCode(const KTextEditor::Cursor &cursor) | | |||
72 | { | | |||
73 | return isCode(cursor.line(), cursor.column()); | | |||
74 | } | | |||
75 | | ||||
76 | bool KateScriptDocument::isCode(const QJSValue &jscursor) | 67 | bool KateScriptDocument::isCode(const QJSValue &jscursor) | ||
77 | { | 68 | { | ||
78 | return isCode(cursorFromScriptValue(jscursor)); | 69 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
70 | return isCode(cursor.line(), cursor.column()); | ||||
79 | } | 71 | } | ||
80 | 72 | | |||
81 | bool KateScriptDocument::isComment(int line, int column) | 73 | bool KateScriptDocument::isComment(int line, int column) | ||
Context not available. | |||||
83 | return m_document->isComment(line, column); | 75 | return m_document->isComment(line, column); | ||
84 | } | 76 | } | ||
85 | 77 | | |||
86 | bool KateScriptDocument::isComment(const KTextEditor::Cursor &cursor) | | |||
87 | { | | |||
88 | return isComment(cursor.line(), cursor.column()); | | |||
89 | } | | |||
90 | | ||||
91 | bool KateScriptDocument::isComment(const QJSValue &jscursor) | 78 | bool KateScriptDocument::isComment(const QJSValue &jscursor) | ||
92 | { | 79 | { | ||
93 | return isComment(cursorFromScriptValue(jscursor)); | 80 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
81 | return isComment(cursor.line(), cursor.column()); | ||||
94 | } | 82 | } | ||
95 | 83 | | |||
96 | bool KateScriptDocument::isString(int line, int column) | 84 | bool KateScriptDocument::isString(int line, int column) | ||
Context not available. | |||||
99 | return defaultStyle == KTextEditor::dsString; | 87 | return defaultStyle == KTextEditor::dsString; | ||
100 | } | 88 | } | ||
101 | 89 | | |||
102 | bool KateScriptDocument::isString(const KTextEditor::Cursor &cursor) | | |||
103 | { | | |||
104 | return isString(cursor.line(), cursor.column()); | | |||
105 | } | | |||
106 | | ||||
107 | bool KateScriptDocument::isString(const QJSValue &jscursor) | 90 | bool KateScriptDocument::isString(const QJSValue &jscursor) | ||
108 | { | 91 | { | ||
109 | return isString(cursorFromScriptValue(jscursor)); | 92 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
93 | return isString(cursor.line(), cursor.column()); | ||||
110 | } | 94 | } | ||
111 | 95 | | |||
112 | bool KateScriptDocument::isRegionMarker(int line, int column) | 96 | bool KateScriptDocument::isRegionMarker(int line, int column) | ||
Context not available. | |||||
115 | return defaultStyle == KTextEditor::dsRegionMarker; | 99 | return defaultStyle == KTextEditor::dsRegionMarker; | ||
116 | } | 100 | } | ||
117 | 101 | | |||
118 | bool KateScriptDocument::isRegionMarker(const KTextEditor::Cursor &cursor) | | |||
119 | { | | |||
120 | return isRegionMarker(cursor.line(), cursor.column()); | | |||
121 | } | | |||
122 | | ||||
123 | bool KateScriptDocument::isRegionMarker(const QJSValue &jscursor) | 102 | bool KateScriptDocument::isRegionMarker(const QJSValue &jscursor) | ||
124 | { | 103 | { | ||
125 | return isRegionMarker(cursorFromScriptValue(jscursor)); | 104 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
105 | return isRegionMarker(cursor.line(), cursor.column()); | ||||
126 | } | 106 | } | ||
127 | 107 | | |||
128 | bool KateScriptDocument::isChar(int line, int column) | 108 | bool KateScriptDocument::isChar(int line, int column) | ||
Context not available. | |||||
131 | return defaultStyle == KTextEditor::dsChar; | 111 | return defaultStyle == KTextEditor::dsChar; | ||
132 | } | 112 | } | ||
133 | 113 | | |||
134 | bool KateScriptDocument::isChar(const KTextEditor::Cursor &cursor) | | |||
135 | { | | |||
136 | return isChar(cursor.line(), cursor.column()); | | |||
137 | } | | |||
138 | | ||||
139 | bool KateScriptDocument::isChar(const QJSValue &jscursor) | 114 | bool KateScriptDocument::isChar(const QJSValue &jscursor) | ||
140 | { | 115 | { | ||
141 | return isChar(cursorFromScriptValue(jscursor)); | 116 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
117 | return isChar(cursor.line(), cursor.column()); | ||||
142 | } | 118 | } | ||
143 | 119 | | |||
144 | bool KateScriptDocument::isOthers(int line, int column) | 120 | bool KateScriptDocument::isOthers(int line, int column) | ||
Context not available. | |||||
147 | return defaultStyle == KTextEditor::dsOthers; | 123 | return defaultStyle == KTextEditor::dsOthers; | ||
148 | } | 124 | } | ||
149 | 125 | | |||
150 | bool KateScriptDocument::isOthers(const KTextEditor::Cursor &cursor) | | |||
151 | { | | |||
152 | return isOthers(cursor.line(), cursor.column()); | | |||
153 | } | | |||
154 | | ||||
155 | bool KateScriptDocument::isOthers(const QJSValue &jscursor) | 126 | bool KateScriptDocument::isOthers(const QJSValue &jscursor) | ||
156 | { | 127 | { | ||
157 | return isOthers(cursorFromScriptValue(jscursor)); | 128 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
129 | return isOthers(cursor.line(), cursor.column()); | ||||
158 | } | 130 | } | ||
159 | 131 | | |||
160 | int KateScriptDocument::firstVirtualColumn(int line) | 132 | int KateScriptDocument::firstVirtualColumn(int line) | ||
Context not available. | |||||
189 | return textLine->toVirtualColumn(column, tabWidth); | 161 | return textLine->toVirtualColumn(column, tabWidth); | ||
190 | } | 162 | } | ||
191 | 163 | | |||
192 | int KateScriptDocument::toVirtualColumn(const KTextEditor::Cursor &cursor) | 164 | int KateScriptDocument::toVirtualColumn(const QJSValue &jscursor) | ||
193 | { | 165 | { | ||
166 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
194 | return toVirtualColumn(cursor.line(), cursor.column()); | 167 | return toVirtualColumn(cursor.line(), cursor.column()); | ||
195 | } | 168 | } | ||
196 | 169 | | |||
197 | int KateScriptDocument::toVirtualColumn(const QJSValue &jscursor) | 170 | QJSValue KateScriptDocument::toVirtualCursor(int line, int column) | ||
198 | { | 171 | { | ||
199 | return toVirtualColumn(cursorFromScriptValue(jscursor)); | 172 | const KTextEditor::Cursor cursor(line, toVirtualColumn(line, column)); | ||
173 | return cursorToScriptValue(m_engine, cursor); | ||||
200 | } | 174 | } | ||
201 | 175 | | |||
202 | KTextEditor::Cursor KateScriptDocument::toVirtualCursor(const KTextEditor::Cursor &cursor) | 176 | QJSValue KateScriptDocument::toVirtualCursor(const QJSValue &jscursor) | ||
203 | { | 177 | { | ||
204 | return KTextEditor::Cursor(cursor.line(), | 178 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
205 | toVirtualColumn(cursor.line(), cursor.column())); | 179 | return toVirtualCursor(cursor.line(), cursor.column()); | ||
206 | } | 180 | } | ||
207 | 181 | | |||
208 | int KateScriptDocument::fromVirtualColumn(int line, int virtualColumn) | 182 | int KateScriptDocument::fromVirtualColumn(int line, int virtualColumn) | ||
Context not available. | |||||
215 | return textLine->fromVirtualColumn(virtualColumn, tabWidth); | 189 | return textLine->fromVirtualColumn(virtualColumn, tabWidth); | ||
216 | } | 190 | } | ||
217 | 191 | | |||
218 | int KateScriptDocument::fromVirtualColumn(const KTextEditor::Cursor &virtualCursor) | 192 | int KateScriptDocument::fromVirtualColumn(const QJSValue &jscursor) | ||
219 | { | 193 | { | ||
220 | return fromVirtualColumn(virtualCursor.line(), virtualCursor.column()); | 194 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
195 | return fromVirtualColumn(cursor.line(), cursor.column()); | ||||
221 | } | 196 | } | ||
222 | 197 | | |||
223 | KTextEditor::Cursor KateScriptDocument::fromVirtualCursor(const KTextEditor::Cursor &virtualCursor) | 198 | QJSValue KateScriptDocument::fromVirtualCursor(int line, int column) | ||
224 | { | 199 | { | ||
225 | return KTextEditor::Cursor(virtualCursor.line(), | 200 | const KTextEditor::Cursor cursor(line, fromVirtualColumn(line, column)); | ||
226 | fromVirtualColumn(virtualCursor.line(), virtualCursor.column())); | 201 | return cursorToScriptValue(m_engine, cursor); | ||
202 | } | ||||
203 | | ||||
204 | QJSValue KateScriptDocument::fromVirtualCursor(const QJSValue &jscursor) | ||||
205 | { | ||||
206 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
207 | return fromVirtualCursor(cursor.line(), cursor.column()); | ||||
227 | } | 208 | } | ||
228 | 209 | | |||
229 | KTextEditor::Cursor KateScriptDocument::rfindInternal(int line, int column, const QString &text, int attribute) | 210 | KTextEditor::Cursor KateScriptDocument::rfindInternal(int line, int column, const QString &text, int attribute) | ||
Context not available. | |||||
380 | return textLine->endsWith(pattern); | 361 | return textLine->endsWith(pattern); | ||
381 | } | 362 | } | ||
382 | 363 | | |||
383 | //BEGIN Automatically generated | | |||
384 | | ||||
385 | QString KateScriptDocument::fileName() | 364 | QString KateScriptDocument::fileName() | ||
386 | { | 365 | { | ||
387 | return m_document->documentName(); | 366 | return m_document->documentName(); | ||
Context not available. | |||||
429 | 408 | | |||
430 | QString KateScriptDocument::text(int fromLine, int fromColumn, int toLine, int toColumn) | 409 | QString KateScriptDocument::text(int fromLine, int fromColumn, int toLine, int toColumn) | ||
431 | { | 410 | { | ||
432 | return text(KTextEditor::Range(fromLine, fromColumn, toLine, toColumn)); | 411 | const KTextEditor::Range range(fromLine, fromColumn, toLine, toColumn); | ||
412 | return m_document->text(range); | ||||
433 | } | 413 | } | ||
434 | 414 | | |||
435 | QString KateScriptDocument::text(const KTextEditor::Cursor &from, const KTextEditor::Cursor &to) | 415 | QString KateScriptDocument::text(const QJSValue &jsfrom, const QJSValue &jsto) | ||
436 | { | 416 | { | ||
437 | return text(KTextEditor::Range(from, to)); | 417 | const KTextEditor::Cursor from = cursorFromScriptValue(jsfrom); | ||
438 | } | 418 | const KTextEditor::Cursor to = cursorFromScriptValue(jsto); | ||
439 | 419 | return text(from.line(), from.column(), to.line(), to.column()); | |||
440 | QString KateScriptDocument::text(const KTextEditor::Range &range) | | |||
441 | { | | |||
442 | return m_document->text(range); | | |||
443 | } | 420 | } | ||
444 | 421 | | |||
445 | QString KateScriptDocument::text(const QJSValue &jsrange) | 422 | QString KateScriptDocument::text(const QJSValue &jsrange) | ||
446 | { | 423 | { | ||
447 | return text(rangeFromScriptValue(jsrange)); | 424 | const KTextEditor::Range range = rangeFromScriptValue(jsrange); | ||
425 | return text(range.start().line(), range.start().column(), range.end().line(), range.end().column()); | ||||
448 | } | 426 | } | ||
449 | 427 | | |||
450 | QString KateScriptDocument::line(int line) | 428 | QString KateScriptDocument::line(int line) | ||
Context not available. | |||||
454 | 432 | | |||
455 | QString KateScriptDocument::wordAt(int line, int column) | 433 | QString KateScriptDocument::wordAt(int line, int column) | ||
456 | { | 434 | { | ||
457 | return wordAt(KTextEditor::Cursor(line, column)); | 435 | const KTextEditor::Cursor cursor(line, column); | ||
458 | } | | |||
459 | | ||||
460 | QString KateScriptDocument::wordAt(const KTextEditor::Cursor &cursor) | | |||
461 | { | | |||
462 | return m_document->wordAt(cursor); | 436 | return m_document->wordAt(cursor); | ||
463 | } | 437 | } | ||
464 | 438 | | |||
465 | QJSValue KateScriptDocument::wordRangeAt(int line, int column) | 439 | QString KateScriptDocument::wordAt(const QJSValue &jscursor) | ||
466 | { | 440 | { | ||
467 | return wordRangeAt(KTextEditor::Cursor(line, column)); | 441 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
442 | return wordAt(cursor.line(), cursor.column()); | ||||
468 | } | 443 | } | ||
469 | 444 | | |||
470 | QJSValue KateScriptDocument::wordRangeAt(const KTextEditor::Cursor &cursor) | 445 | QJSValue KateScriptDocument::wordRangeAt(int line, int column) | ||
471 | { | 446 | { | ||
447 | const KTextEditor::Cursor cursor(line, column); | ||||
472 | return rangeToScriptValue(m_engine, m_document->wordRangeAt(cursor)); | 448 | return rangeToScriptValue(m_engine, m_document->wordRangeAt(cursor)); | ||
473 | } | 449 | } | ||
474 | 450 | | |||
475 | QString KateScriptDocument::charAt(int line, int column) | 451 | QJSValue KateScriptDocument::wordRangeAt(const QJSValue &jscursor) | ||
476 | { | 452 | { | ||
477 | return charAt(KTextEditor::Cursor(line, column)); | 453 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
454 | return wordRangeAt(cursor.line(), cursor.column()); | ||||
478 | } | 455 | } | ||
479 | 456 | | |||
480 | QString KateScriptDocument::charAt(const KTextEditor::Cursor &cursor) | 457 | QString KateScriptDocument::charAt(int line, int column) | ||
481 | { | 458 | { | ||
459 | const KTextEditor::Cursor cursor(line, column); | ||||
482 | const QChar c = m_document->characterAt(cursor); | 460 | const QChar c = m_document->characterAt(cursor); | ||
483 | return c.isNull() ? QString() : QString(c); | 461 | return c.isNull() ? QString() : QString(c); | ||
484 | } | 462 | } | ||
485 | 463 | | |||
486 | QString KateScriptDocument::charAt(const QJSValue &jscursor) | 464 | QString KateScriptDocument::charAt(const QJSValue &jscursor) | ||
487 | { | 465 | { | ||
488 | return charAt(cursorFromScriptValue(jscursor)); | 466 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
467 | return charAt(cursor.line(), cursor.column()); | ||||
489 | } | 468 | } | ||
490 | 469 | | |||
491 | QString KateScriptDocument::firstChar(int line) | 470 | QString KateScriptDocument::firstChar(int line) | ||
Context not available. | |||||
512 | 491 | | |||
513 | bool KateScriptDocument::isSpace(int line, int column) | 492 | bool KateScriptDocument::isSpace(int line, int column) | ||
514 | { | 493 | { | ||
515 | return isSpace(KTextEditor::Cursor(line, column)); | 494 | const KTextEditor::Cursor cursor(line, column); | ||
516 | } | | |||
517 | | ||||
518 | bool KateScriptDocument::isSpace(const KTextEditor::Cursor &cursor) | | |||
519 | { | | |||
520 | return m_document->characterAt(cursor).isSpace(); | 495 | return m_document->characterAt(cursor).isSpace(); | ||
521 | } | 496 | } | ||
522 | 497 | | |||
523 | bool KateScriptDocument::isSpace(const QJSValue &jscursor) | 498 | bool KateScriptDocument::isSpace(const QJSValue &jscursor) | ||
524 | { | 499 | { | ||
525 | return isSpace(cursorFromScriptValue(jscursor)); | 500 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
501 | return isSpace(cursor.line(), cursor.column()); | ||||
526 | } | 502 | } | ||
527 | 503 | | |||
528 | bool KateScriptDocument::matchesAt(int line, int column, const QString &s) | 504 | bool KateScriptDocument::matchesAt(int line, int column, const QString &s) | ||
Context not available. | |||||
531 | return textLine ? textLine->matchesAt(column, s) : false; | 507 | return textLine ? textLine->matchesAt(column, s) : false; | ||
532 | } | 508 | } | ||
533 | 509 | | |||
534 | bool KateScriptDocument::matchesAt(const KTextEditor::Cursor &cursor, const QString &s) | | |||
535 | { | | |||
536 | | ||||
537 | return matchesAt(cursor.line(), cursor.column(), s); | | |||
538 | } | | |||
539 | | ||||
540 | bool KateScriptDocument::matchesAt(const QJSValue &jscursor, const QString &s) | 510 | bool KateScriptDocument::matchesAt(const QJSValue &jscursor, const QString &s) | ||
541 | { | 511 | { | ||
542 | 512 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | |||
543 | KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | 513 | return matchesAt(cursor.line(), cursor.column(), s); | ||
544 | return matchesAt(cursor, s); | | |||
545 | } | 514 | } | ||
546 | 515 | | |||
547 | bool KateScriptDocument::setText(const QString &s) | 516 | bool KateScriptDocument::setText(const QString &s) | ||
Context not available. | |||||
561 | return false; | 530 | return false; | ||
562 | } | 531 | } | ||
563 | 532 | | |||
564 | KTextEditor::Cursor from(line, column), to(line, textLine->text().size() - column); | 533 | return removeText(line, column, line, textLine->text().size() - column); | ||
565 | return removeText(KTextEditor::Range(from, to)); | | |||
566 | } | 534 | } | ||
567 | 535 | | |||
568 | bool KateScriptDocument::truncate(const KTextEditor::Cursor &cursor) | 536 | bool KateScriptDocument::truncate(const QJSValue &jscursor) | ||
569 | { | 537 | { | ||
538 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
570 | return truncate(cursor.line(), cursor.column()); | 539 | return truncate(cursor.line(), cursor.column()); | ||
571 | } | 540 | } | ||
572 | 541 | | |||
573 | bool KateScriptDocument::truncate(const QJSValue &cursor) | | |||
574 | { | | |||
575 | return truncate(cursorFromScriptValue(cursor)); | | |||
576 | } | | |||
577 | | ||||
578 | bool KateScriptDocument::insertText(int line, int column, const QString &s) | 542 | bool KateScriptDocument::insertText(int line, int column, const QString &s) | ||
579 | { | 543 | { | ||
580 | return insertText(KTextEditor::Cursor(line, column), s); | 544 | KTextEditor::Cursor cursor(line, column); | ||
581 | } | | |||
582 | | ||||
583 | bool KateScriptDocument::insertText(const KTextEditor::Cursor &cursor, const QString &s) | | |||
584 | { | | |||
585 | return m_document->insertText(cursor, s); | 545 | return m_document->insertText(cursor, s); | ||
586 | } | 546 | } | ||
587 | 547 | | |||
588 | bool KateScriptDocument::insertText(const QJSValue &jscursor, const QString &s) | 548 | bool KateScriptDocument::insertText(const QJSValue &jscursor, const QString &s) | ||
589 | { | 549 | { | ||
590 | KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | 550 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
591 | return insertText(cursor, s); | 551 | return insertText(cursor.line(), cursor.column(), s); | ||
592 | } | 552 | } | ||
593 | 553 | | |||
594 | bool KateScriptDocument::removeText(int fromLine, int fromColumn, int toLine, int toColumn) | 554 | bool KateScriptDocument::removeText(int fromLine, int fromColumn, int toLine, int toColumn) | ||
595 | { | 555 | { | ||
596 | return removeText(KTextEditor::Range(fromLine, fromColumn, toLine, toColumn)); | 556 | const KTextEditor::Range range(fromLine, fromColumn, toLine, toColumn); | ||
557 | return m_document->removeText(range); | ||||
597 | } | 558 | } | ||
598 | 559 | | |||
599 | bool KateScriptDocument::removeText(const KTextEditor::Cursor &from, const KTextEditor::Cursor &to) | 560 | bool KateScriptDocument::removeText(const QJSValue &jsfrom, const QJSValue &jsto) | ||
600 | { | 561 | { | ||
601 | return removeText(KTextEditor::Range(from, to)); | 562 | const KTextEditor::Cursor from = cursorFromScriptValue(jsfrom); | ||
602 | } | 563 | const KTextEditor::Cursor to = cursorFromScriptValue(jsto); | ||
603 | 564 | return removeText(from.line(), from.column(), to.line(), to.column()); | |||
604 | bool KateScriptDocument::removeText(const KTextEditor::Range &range) | | |||
605 | { | | |||
606 | return m_document->removeText(range); | | |||
607 | } | 565 | } | ||
608 | 566 | | |||
609 | bool KateScriptDocument::removeText(const QJSValue &jsrange) | 567 | bool KateScriptDocument::removeText(const QJSValue &jsrange) | ||
610 | { | 568 | { | ||
611 | KTextEditor::Range range = rangeFromScriptValue(jsrange); | 569 | const KTextEditor::Range range = rangeFromScriptValue(jsrange); | ||
612 | return removeText(range); | 570 | return removeText(range.start().line(), range.start().column(), range.end().line(), range.end().column()); | ||
613 | } | 571 | } | ||
614 | 572 | | |||
615 | bool KateScriptDocument::insertLine(int line, const QString &s) | 573 | bool KateScriptDocument::insertLine(int line, const QString &s) | ||
Context not available. | |||||
627 | return m_document->editWrapLine(line, column); | 585 | return m_document->editWrapLine(line, column); | ||
628 | } | 586 | } | ||
629 | 587 | | |||
630 | bool KateScriptDocument::wrapLine(const KTextEditor::Cursor &cursor) | | |||
631 | { | | |||
632 | return wrapLine(cursor.line(), cursor.column()); | | |||
633 | } | | |||
634 | | ||||
635 | bool KateScriptDocument::wrapLine(const QJSValue &jscursor) | 588 | bool KateScriptDocument::wrapLine(const QJSValue &jscursor) | ||
636 | { | 589 | { | ||
637 | return wrapLine(cursorFromScriptValue(jscursor)); | 590 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
591 | return wrapLine(cursor.line(), cursor.column()); | ||||
638 | } | 592 | } | ||
639 | 593 | | |||
640 | void KateScriptDocument::joinLines(int startLine, int endLine) | 594 | void KateScriptDocument::joinLines(int startLine, int endLine) | ||
Context not available. | |||||
692 | return m_document->isValidTextPosition(KTextEditor::Cursor(line, column)); | 646 | return m_document->isValidTextPosition(KTextEditor::Cursor(line, column)); | ||
693 | } | 647 | } | ||
694 | 648 | | |||
695 | bool KateScriptDocument::isValidTextPosition(const KTextEditor::Cursor& cursor) | | |||
696 | { | | |||
697 | return m_document->isValidTextPosition(cursor); | | |||
698 | } | | |||
699 | | ||||
700 | bool KateScriptDocument::isValidTextPosition(const QJSValue& cursor) | 649 | bool KateScriptDocument::isValidTextPosition(const QJSValue& cursor) | ||
701 | { | 650 | { | ||
702 | return m_document->isValidTextPosition(cursorFromScriptValue(cursor)); | 651 | return m_document->isValidTextPosition(cursorFromScriptValue(cursor)); | ||
Context not available. | |||||
723 | return textLine->previousNonSpaceChar(column); | 672 | return textLine->previousNonSpaceChar(column); | ||
724 | } | 673 | } | ||
725 | 674 | | |||
726 | int KateScriptDocument::prevNonSpaceColumn(const KTextEditor::Cursor &cursor) | 675 | int KateScriptDocument::prevNonSpaceColumn(const QJSValue &jscursor) | ||
727 | { | 676 | { | ||
677 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
728 | return prevNonSpaceColumn(cursor.line(), cursor.column()); | 678 | return prevNonSpaceColumn(cursor.line(), cursor.column()); | ||
729 | } | 679 | } | ||
730 | 680 | | |||
731 | int KateScriptDocument::prevNonSpaceColumn(const QJSValue &cursor) | | |||
732 | { | | |||
733 | return prevNonSpaceColumn(cursorFromScriptValue(cursor)); | | |||
734 | } | | |||
735 | | ||||
736 | int KateScriptDocument::nextNonSpaceColumn(int line, int column) | 681 | int KateScriptDocument::nextNonSpaceColumn(int line, int column) | ||
737 | { | 682 | { | ||
738 | Kate::TextLine textLine = m_document->plainKateTextLine(line); | 683 | Kate::TextLine textLine = m_document->plainKateTextLine(line); | ||
Context not available. | |||||
742 | return textLine->nextNonSpaceChar(column); | 687 | return textLine->nextNonSpaceChar(column); | ||
743 | } | 688 | } | ||
744 | 689 | | |||
745 | int KateScriptDocument::nextNonSpaceColumn(const KTextEditor::Cursor &cursor) | 690 | int KateScriptDocument::nextNonSpaceColumn(const QJSValue &jscursor) | ||
746 | { | 691 | { | ||
692 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
747 | return nextNonSpaceColumn(cursor.line(), cursor.column()); | 693 | return nextNonSpaceColumn(cursor.line(), cursor.column()); | ||
748 | } | 694 | } | ||
749 | 695 | | |||
750 | int KateScriptDocument::nextNonSpaceColumn(const QJSValue &cursor) | | |||
751 | { | | |||
752 | return nextNonSpaceColumn(cursorFromScriptValue(cursor)); | | |||
753 | } | | |||
754 | | ||||
755 | int KateScriptDocument::prevNonEmptyLine(int line) | 696 | int KateScriptDocument::prevNonEmptyLine(int line) | ||
756 | { | 697 | { | ||
757 | const int startLine = line; | 698 | const int startLine = line; | ||
Context not available. | |||||
831 | return textLine->attribute(column); | 772 | return textLine->attribute(column); | ||
832 | } | 773 | } | ||
833 | 774 | | |||
834 | int KateScriptDocument::attribute(const KTextEditor::Cursor &cursor) | 775 | int KateScriptDocument::attribute(const QJSValue &jscursor) | ||
835 | { | 776 | { | ||
777 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
836 | return attribute(cursor.line(), cursor.column()); | 778 | return attribute(cursor.line(), cursor.column()); | ||
837 | } | 779 | } | ||
838 | 780 | | |||
Context not available. | |||||
841 | return attr == attribute(line, column); | 783 | return attr == attribute(line, column); | ||
842 | } | 784 | } | ||
843 | 785 | | |||
844 | bool KateScriptDocument::isAttribute(const KTextEditor::Cursor &cursor, int attr) | 786 | bool KateScriptDocument::isAttribute(const QJSValue &jscursor, int attr) | ||
845 | { | 787 | { | ||
788 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||||
846 | return isAttribute(cursor.line(), cursor.column(), attr); | 789 | return isAttribute(cursor.line(), cursor.column(), attr); | ||
847 | } | 790 | } | ||
848 | 791 | | |||
Context not available. | |||||
854 | return a->name(); | 797 | return a->name(); | ||
855 | } | 798 | } | ||
856 | 799 | | |||
857 | QString KateScriptDocument::attributeName(const KTextEditor::Cursor &cursor) | | |||
858 | { | | |||
859 | return attributeName(cursor.line(), cursor.column()); | | |||
860 | } | | |||
861 | | ||||
862 | QString KateScriptDocument::attributeName(const QJSValue &jscursor) | 800 | QString KateScriptDocument::attributeName(const QJSValue &jscursor) | ||
863 | { | 801 | { | ||
864 | return attributeName(cursorFromScriptValue(jscursor)); | 802 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
803 | return attributeName(cursor.line(), cursor.column()); | ||||
865 | } | 804 | } | ||
866 | 805 | | |||
867 | bool KateScriptDocument::isAttributeName(int line, int column, const QString &name) | 806 | bool KateScriptDocument::isAttributeName(int line, int column, const QString &name) | ||
Context not available. | |||||
869 | return name == attributeName(line, column); | 808 | return name == attributeName(line, column); | ||
870 | } | 809 | } | ||
871 | 810 | | |||
872 | bool KateScriptDocument::isAttributeName(const KTextEditor::Cursor &cursor, const QString &name) | | |||
873 | { | | |||
874 | return isAttributeName(cursor.line(), cursor.column(), name); | | |||
875 | } | | |||
876 | | ||||
877 | bool KateScriptDocument::isAttributeName(const QJSValue &jscursor, const QString &name) | 811 | bool KateScriptDocument::isAttributeName(const QJSValue &jscursor, const QString &name) | ||
878 | { | 812 | { | ||
879 | KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | 813 | const KTextEditor::Cursor cursor = cursorFromScriptValue(jscursor); | ||
880 | return isAttributeName(cursor, name); | 814 | return isAttributeName(cursor.line(), cursor.column(), name); | ||
881 | } | 815 | } | ||
882 | 816 | | |||
883 | QString KateScriptDocument::variable(const QString &s) | 817 | QString KateScriptDocument::variable(const QString &s) | ||
Context not available. | |||||
890 | m_document->setVariable(s, v); | 824 | m_document->setVariable(s, v); | ||
891 | } | 825 | } | ||
892 | 826 | | |||
893 | //END | | |||
894 | | ||||
895 | bool KateScriptDocument::_isCode(int defaultStyle) | 827 | bool KateScriptDocument::_isCode(int defaultStyle) | ||
896 | { | 828 | { | ||
897 | return (defaultStyle != KTextEditor::dsComment | 829 | return (defaultStyle != KTextEditor::dsComment | ||
Context not available. | |||||
901 | && defaultStyle != KTextEditor::dsOthers); | 833 | && defaultStyle != KTextEditor::dsOthers); | ||
902 | } | 834 | } | ||
903 | 835 | | |||
904 | void KateScriptDocument::indent(KTextEditor::Range range, int change) | | |||
905 | { | | |||
906 | m_document->indent(range, change); | | |||
907 | } | | |||
908 | | ||||
909 | void KateScriptDocument::indent(const QJSValue &jsrange, int change) | 836 | void KateScriptDocument::indent(const QJSValue &jsrange, int change) | ||
910 | { | 837 | { | ||
911 | KTextEditor::Range range = rangeFromScriptValue(jsrange); | 838 | const KTextEditor::Range range = rangeFromScriptValue(jsrange); | ||
912 | indent(range, change); | 839 | m_document->indent(range, change); | ||
913 | } | 840 | } | ||
Context not available. |