Cursor line end

Script key: Cursor line end

Posted by Xor

Install

Details

Label
Voice Over Cursor line end
Script
var text = getText()
var n = text.length
var selRange = getSelectedRange()

var p = selRange[0]
var q = p + selRange[1]

selectLine()
if (q < n - 1 && q === selRange[0] + selRange[1] && p === q) {
  ++q
}

setSelectedRange(q, 0)

function selectLine() {
  var i = p
  var delim = /^[\n]$/
  
  while (i > 0) {
    if (delim.test(text[i - 1]))
      break
  
    --i
  }
  
  var j = q
  
  while (j < n) {
    if (delim.test(text[j]))
      break
    ++j
  }

  //++j
  
  //if (j-i)
  //  setSelectedRange(i, j-i)
  p = i
  q = j
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus