⌘V
Paste

Script key: Paste

Posted by Xor

Install

Details

Label ⌘V
Voice Over Paste
Script
var text = getText()
var n = text.length
var selRange = getSelectedRange()

var i, j

var sel = getSelectedText()

var clipboard = getClipboard()

if (selRange[1] === 0 &&
    clipboard.indexOf('\n') === clipboard.length-1) {
  selectLine()
  setSelectedRange(i, 0)
  setSelectedText(clipboard);
  setSelectedRange(selRange[0]+clipboard.length,0);
} else {
  setSelectedText(clipboard);
  setSelectedRange(selRange[0]+clipboard.length,0);
}

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

  ++j
  
  //if (j-i)
  //  setSelectedRange(i, j-i)
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus