cursorEndLine moves the cursor to the end of the text
()
| 528 | |
| 529 | // cursorEndLine moves the cursor to the end of the text |
| 530 | func (ed *Editor) cursorEndLine() { |
| 531 | ed.validateCursor() |
| 532 | org := ed.CursorPos |
| 533 | pos := ed.CursorPos |
| 534 | |
| 535 | gotwrap := false |
| 536 | if wln := ed.wrappedLines(pos.Ln); wln > 1 { |
| 537 | si, ri, _ := ed.wrappedLineNumber(pos) |
| 538 | ri = len(ed.renders[pos.Ln].Spans[si].Text) - 1 |
| 539 | nwc, _ := ed.renders[pos.Ln].SpanPosToRuneIndex(si, ri) |
| 540 | if si == len(ed.renders[pos.Ln].Spans)-1 { // last span |
| 541 | ri++ |
| 542 | nwc++ |
| 543 | } |
| 544 | ed.cursorColumn = ri |
| 545 | pos.Ch = nwc |
| 546 | ed.CursorPos = pos |
| 547 | gotwrap = true |
| 548 | } |
| 549 | if !gotwrap { |
| 550 | ed.CursorPos.Ch = ed.Buffer.LineLen(ed.CursorPos.Ln) |
| 551 | ed.cursorColumn = ed.CursorPos.Ch |
| 552 | } |
| 553 | ed.setCursor(ed.CursorPos) |
| 554 | ed.scrollCursorToRight() |
| 555 | ed.renderCursor(true) |
| 556 | ed.cursorSelect(org) |
| 557 | ed.NeedsRender() |
| 558 | } |
| 559 | |
| 560 | // cursorEndDoc moves the cursor to the end of the text, updating selection if |
| 561 | // select mode is active |
no test coverage detected