Action

Show invisibles in clipboard

Posted by @ComplexPoint, Last update almost 6 years 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

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
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.