⌘C
Copy

Script key: Copy

Posted by Xor

Install

Details

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

var i, j

if (selRange[1])
  setClipboard(getSelectedText())
else {
  selectLine()
  setClipboard(text.substring(i, j))
}

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