Drafts Action Directory

Show invisibles in clipboard

Posted by @ComplexPoint, Last update 3 months ago

Display textual clipboard contents,
with non-printing characters (tabs, spaces, newlines etc), made visible.

Useful, for example, for spotting unexpected mixtures of tabs and spaces.

Displays a dialog showing a view of the clipboard contents like:

Project:\n
\t-.with.a.mixture.of.tabs\n
....-.and.multiple.spaces\n
...-.possibly.of.inconsistent.number\n
\t-.etc\n
\t-.and.so.forth
Install

Steps

  • script

    (() => {
        'use strict';
    
        const
            strClip = app.getClipboard() || '',
            strVisible = (strClip.length > 0 ? (
                JSON.stringify(strClip) // Visible escapes,
                .slice(1, -1)           // without flanking quotes,
                .replace(/ /g, '.')     // using . to show spaces,
                .split('\\n')           // and breaking the string
            ) : []).join('\\n\n'),      // into lines with visible \n
            p = Object.assign(
                Prompt.create(), {
                    title: 'Invisibles in clipboard',
                    message: 'Non-printing chars shown as:\n\n' +
                        'tab: \\t\nlinefeed: \\n\nspace: .'
                }
            );
        return (
            p.addTextView(
                'txt',
                'in clipboard:',
                strVisible, {
                    height: 240
                }
            ),
            p.show(),
            strVisible
        );
    })()
    

Options

  • After Success Default
    Notification Error
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.