Trim input to clipboard #2812
aleskomarek
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
Is it possible adding option to configuration for trimming white spaces on single line string inputed to clipboard and also option for removing blank lines before/after inputed string to clipboard?
I'm trying this command, but sometimes it has strange behavior.
copyq:
var text = str(clipboard()).replace(/\s+$/, '')
var lines = text.split('\n')
var trimmed_lines = []
for (var i = 0; i < lines.length; i++){
var tri = lines[i].replace(/\s+$/, '')
trimmed_lines.push(tri)
//popup(''+" + i +" = " + tri +'')
}
var output = trimmed_lines.join('\n')
//popup(''+output+'')
var isDuplicate = false
for (var i = 0; i < size(); ++i){
if (str(read(i)) == output){
isDuplicate = true
//popup('duplicate[' + i + ']: ' + output)
if(i != 0){
remove(i)
insert(0, output)
}
break
}
}
if (!isDuplicate) {
if(hasClipboardFormat(mimeHtml)){
//popup('text/plain + html: ' + output)
write(0, 'text/plain', output, 'text/html', clipboard(mimeHtml))
copy(mimeText, output, mimeHtml, clipboard(mimeHtml))
} else {
//popup('text/plain: ' + output)
write(0, output)
copy(output)
}
}
Thank You very much.
Best regards,
Ales
Beta Was this translation helpful? Give feedback.
All reactions