Zren / plasma-applet-commandoutput

https://store.kde.org/p/1166510/
GNU General Public License v2.0
90 stars 17 forks source link

keep the ending em-space? #11

Closed roachsinai closed 5 years ago

roachsinai commented 5 years ago

Is there a way to keep the ending em-spaces?

Now behavior:

screenshot_20190223_155131

hmank ~ > echo "  12  "
  12  
hmank ~ > 

cause echo get the em-space, does the reason is https://github.com/Zren/plasma-applet-commandoutput/blob/50f97fffc04e577b4e38cdb12cf9be204d7bbe24/package/contents/ui/main.qml#L64 ?

And behavior after add something in the begining and ending:

screenshot_20190223_155458

Expected behavior

trim spaces not em-spaces.

Zren commented 5 years ago

QML's trim function follow's the ECMA standard and removes all whitespace

http://www.ecma-international.org/ecma-262/9.0/index.html#prod-WhiteSpace WhiteSpace:: <TAB> <VT> <FF> <SP> <NBSP> <ZWNBSP> <USP> Other category “Zs” | Any other Unicode “Space_Separator” code point | <USP>

https://en.wikipedia.org/wiki/Whitespace_character U+2003 | em space | 8195 | ... | Also known as "mutton". Width of one em. U+2001 Em Quad is canonically equivalent to this character; U+2003 is preferred. HTML/XML named entity: &emsp;

Are you asking for a checkbox to disable the trimming? What you're after could probably be done with a "spacer" (there should be an "Add Spacer" button when editing the panel).

You should be able to just remove the .trim() call. You'll probably have a space where the final newline (\n) is, so replace the newline with an empty string instead.

// widget.outputText = stdout.replace('\n', ' ').trim()
// widget.outputText = stdout.replace('\n', ' ')
widget.outputText = stdout.replace('\n', '')
roachsinai commented 5 years ago

Thanks!