How to enter spacebar space character in Block Composer - ShowText()? - pdfclown

When I'm using ShowText's whitespace (spacebar spaces) (in Block Composer), it only works in middle of the texts but not at the beginning of the text. I assumed it is because PDFClown do trim the whitespace characters.
So is there special character I can use in place of whitespace so it won't get trimmed?

Yes, leading whitespace is purposely trimmed off: if you need to indent your paragraph then use the BlockComposer.ShowBreak(SizeF) method specifying a horizontal offset (for example blockComposer.ShowBreak(new SizeF(10,0))).

Related

Change zsh theme if too long

If I have an ohmyzsh theme that uses %~/ to get the current directory path. Is there a way to tell it that if the line length requires wrapping onto a new line, to use just the current directory without the full path?
Not exactly, but Zsh can actually do something better than that! You can use %-X<Y<Z%<< to ensure you always have at least X characters remaining after your prompt, by trimming the left side of Z and replacing the trimmed part with Y. (Note that Y itself is always printed literally and any prompt escape sequences inside it will not be expanded. If you want to style Y differently from Z, you will have to put the prompt escapes before and after %X<Y<.)
For example:
PS1=$'\n%-40<...<%~%<<%# '
What this does:
If expanding %~ would leave 40 or more characters of empty space on the line, then expand it in full.
Else, print a ... to the left of %~ and trim off characters from the left of %~'s expansion until our prompt leaves exactly 40 characters of empty space on the line.
Always expand %# after this (since it occurs after %<<).
The nice thing about this is that it works for the current prompt even when you resize your terminal. Just try it and you'll see it will dynamically add or remove characters as you resize.

Escape special characters in reStructuredText Sphinx

For my documentation, I want escape special characters.
Example :
.. code-block:: terminal
$ php bin/console test:user
Press <return> for continue
For Sphinx, it's an external URL <return> and I want escape that.
Screenshot :
See Escaping Mechanism:
A backslash followed by any character (except whitespace characters in non-URI contexts) escapes that character. The escaped character represents the character itself, and is prevented from playing a role in any markup interpretation. The backslash is removed from the output.
To answer your question, you can use various markup techniques.
Escape the opening and closing brackets.
Press \<return\> for continue
Use inline literal markup.
Press ``<return>`` for continue
Use semantic markup with the kbd role:
Press :kbd:`<return>` for continue
IMO, the last option is the most appropriate for this situation. The first option is the least appropriate.

NSLeftTextAlignment with spaces at end of string

if I sets NSCenterTextAlignment for my NSTextView
my whitespaces at the end of string magically disappears
for example I have string
#"while "
if I display it with NSRightTextAlignment it shows well
|white |
but with NSLeftTextAlignment all whitespaces just cut
|white|
how can I get results like
| white|
tabs is not an option
Just a guess: it sounds as if you are trying to left-align centered items by using spaces to pad some of them. If you must do this you can use non-breaking spaces (UTF-16 0x00A0, type as option-space). HTH

Input color control chars in Textmate

I can use VIM to input these color control chars by "Ctrl-V, Esc" then it will show me ^[ as a special leading char for color control chars sequence.
How could I do this in Textmate?
Thanks
You can select those from the character viewer (Menu Edit -> Special Characters, then search for 'escape'), but I think you'd be better off using an escaped form of that character, e.g. \033 in Bash or \x1b in PHP. That, of course, would depend on what kind of document you're editing.

How is a paragraph defined in an NSAttributedString?

I see that there is an attribute name (NSParagraphStyleAttributeName) for applying paragraph styles to text in Cocoa. Text is stored in an NSAttributedString, but what defines a "paragraph" in that string -- is it the newline character \n? Other characters? If it's a \n, then how do you create a new line without starting a new paragraph. And lastly, when you attach a ParagraphStyle to the string, do you have to use the exact range of the whole paragraph, or can you put it on any sub-range in the paragraph. If it can be a sub-range, how does the system handle two or more ParagraphStyles on the same paragraph?
thanks,
Rob
I got an answer from Douglas on Apple's cocoa-dev mailing list:
http://lists.apple.com/archives/Cocoa-dev/2010/Dec/msg00347.html
I'll copy what he wrote here:
Any of the standard paragraph separators can be used (\n, \r, \r\n, Unicode paragraph separator). Use the Unicode line separator character to start a new line without a paragraph break. It is best to apply a paragraph style to an entire paragraph; if that is not done, then the paragraph style attribute will be automatically fixed at attribute fixing time so that it is constant over each paragraph range, because that is needed at layout time.
It might be worth mentioning that Apple's String Programming Guide has a section on Paragraph and Line Breaks, and that NSString will give you the paragraph ranges without your having to search for paragraph separators.
the best way in iOS from my experience is to use
#"\n\r";
i found inconsistent behaviour with just using \n or even 0x2029 (which should be the equivalent of NSParagraphSeparatorCharacter (not defined in iOS))
the problems emerged when using NSAttributedString and NSParagraphStyle... as when using the #"\n" or (0x2029) the setParagraphSpacing was ignored by other than the first paragraph... using #"\n\r" got the paragraphes right

Resources