Length of titlebar overrun in QB64 - basic

Need to know the length of titlebar in QB64 before it overruns length?
I am using
S$ = "Title"
_TITLE S$
where I need to truncate it before displays "..."
thanks.

Related

How to trim white spaces at the end of a string in Marie?

Hi I'm new to Marie programming language and I have a string with the address NameAddr.
My print subroutine stops printing when it reaches a 0 character (marking the end of the string).So to trim the white spaces I simply iterate backwards from the address of the last character and as long as its a white space I replace it with a 0.
However, my removeSpace subroutine does not terminate and when I step through it its not updating the LastCharAddr properly after I pass in the address of the last character?
//Remove spaces
LastCharAddr, HEX 0
RemoveSpace, HEX 0
Space, DEC 32 //constant needed for subroutine
CharacterReplace, Hex 000 //constant for subroutine
StartRemoveSpace, LoadI LastCharAddr
Subt Space
Skipcond 400 //If its a space
JumpI RemoveSpace //if not a space terminate
Load CharacterReplace //replace with 0
Store LastCharAddr //Replace
Load LastCharAddr
Subt One// iterate backwards
Store LastCharAddr
Jump StartRemoveSpace
Any help will be appreciated thanks!

Howto encode special characters with haskell PDF EasyRender package?

I am using the Graphics.EasyRender haskell package to render PDF files.
Everything is fine with normal ascii characters, but I get encoding problems when using for example German Umlauts like öäüß or french chars like éè etc.
let document = newpage_defer $ do
textbox align_left (Font Helvetica 12) (Color_Gray 0) 10 100 100 100 0 myStr
myStr :: String
myStr = "test text ä"
the output is
test text ˆ⁄
I also tried to encode UTF8, but then it gets worse:
test text ˆ´⁄
As a test I also tries to generate postcript output from the EasyRender package, but there I have the same problems.
PDF is my main concern, any Idea how use these Umlauts in the target PDF?
Each PDF font has its own encoding, and usually PDF files has them embedded together with encoding information. easyrender doesn't embed fonts, it uses standard PDF fonts, that are deprecated.
AFAIU, Helverica uses the StandardEncoding (see PDF reference for details), and it doesn't contain ä character. So I don't think you can non-ASCII characters with easyrender.
To confirm, try to draw a string with byte (octal) 341 (and also 256 and 306 in case it uses MacRomanEncoding or WinAnsiEncoding), it should represent character Æ.
ADDED: Character ä in UTF8 is represented as two bytes, 303 and 244. In the StandardEncoding they represent ˆ and ⁄ -- exactly what you see in the first output. Not sure where ´ comes from in the second one.
There are two issues:
Re-encoding a standard font like Helvetica to be able to "show" characters in the range 128-255.
Representing characters 128-255 in a Postscript string.
The first is covered in Section 5.9.1 of the Postscript Language Reference, page 349. Another reference is http://apps.jcns.fz-juelich.de/doku/sc/ps-latin
The second is a deficiency with the easyrender library. One way to represent the character Ä (capital A with an umlaut) is via the octal
escape \304. That is, in the Postscript file you need to have:
(\304) show
However, looking at the library's source code, the function ps_escape is incapable of producing octal escape codes for characters in the range 128-255.
Another way to solve this problem is to emit the generated Postscript in the Latin1 encoding:
import System.IO
...
main = do
let doc = newpage_defer $ do
...
let output = render_string Format_PDF doc
hSetEncoding stdout latin1
putStr output
Putting these two ideas together:
import Graphics.EasyRender
import System.IO
reencode_fonts = " /Helvetica findfont dup length dict begin { 1 index /FID ne {def} {pop pop} ifelse } forall /Encoding ISOLatin1Encoding def currentdict end /Helvetica exch definefont pop"
my_custom = custom { ps_defs = reencode_fonts }
document = newpage_defer $ do
textbox align_left (Font Helvetica 12) (Color_Gray 0) 10 100 100 100 0 myStr
endpage 500 500
myStr :: String
myStr = "test text ä"
out = render_custom_string Format_PS my_custom document
main = do
hSetEncoding stdout latin1
putStr out

Creating a handler to increase font size

I am working on a text app, which includes a button to increase text size of selected text in a field.
Below is the handler I am using, it works fine when all the selectedText is currently the same size. If some of the text is a different size, the handler returns this error:
execution error at line 42 (Operators +: error in left operand), char
68
The handler:
on txtSizeUp
set the textSize of selectedText to the textSize of selectedText + 2
end txtSizeUp
WHat do I need to do to change the size regardless of difference?
Change your handler to use the selectedChunk instead of the selectedText.
on txtSizeUp
set the textSize of the selectedChunk to the textSize of the selectedChunk + 1
end txtSizeUp
And for good measure, of course:
on txtSizeDown
set the textSize of the selectedChunk to the textSize of the selectedChunk - 1
end txtSizeDown
Edit: The handlers above only work if the textSize of the entire selectedChunk is the same. You want to be able to increment the text size even if there are different sizes within the selection. (I had missed that detail in your original question.)
The problem is that the selectedChunk function returns the string "mixed" when there are varying sizes within the selection. That is why you were getting an error; the set statement was trying to add mixed + 1, a data type mismatch. Here is a handler that should do what you want.
on txtSizeUp
put the effective textSize of the selectedChunk into tSize
if tSize is a number then
set the textSize of the selectedChunk to \
the effective textSize of the selectedChunk + 1
else
lock screen
put the long name of the selectedField into tFld
put word 2 of the selectedChunk into tStartChar
put word 4 of the selectedChunk into tEndChar
repeat with x = tStartChar to tEndChar
set the textSize of char x of tFld to \
the effective textSize of char x of tFld +1
end repeat
unlock screen
end if
end txtSizeUp
There will be other approaches that will work, but they will all involve looping through the selected text in some way.
When setting the textSize, LC needs a chunk expression, like line 3 of fld 1 or word 2 to 4 of fld "yourField"
The phrase the selectedText resolves to the actual text of the selection. So if you had "my dog has fleas" in a field, with "dog" selected, your code is asking to:
set the textSize of "dog" to someValue
This is not allowed. The engine would have no idea what to do. You need to modify your script, and your methodology, to make chunk, not text references.

C++ - Tab control - & character

I'm creating several tabs in my project, and when I use '&' char it isn't displayed as it should be.
For example:
"Tab &1" -> number is underlined
So I figured that I could use:
"Tab &&1" -> and that result in "Tab &1"
I could add additional '&' manually, but I don't know if there are any more chars that don't work straight forward.
I didn't found any reference on my problem and tab names in my project aren't static.
Here is what I do on WM_CREATE:
RECT rcClient;
GetClientRect(hwnd, &rcClient);
TabControl = CreateWindow(WC_TABCONTROL, "", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,0, 0, rcClient.right, rcClient.bottom, hwnd, (HMENU)0, GetModuleHandle(NULL), NULL);
TCITEM tie;
tie.mask = TCIF_TEXT;
tie.pszText = "Tab &&1";
TabCtrl_InsertItem(TabControl, 0, &tie);
Well, Unicode is a mountain of special characters, have some fun googling "zalgo".
But the behavior of the & character, and just that particular one, is nailed down as special in the DrawTextEx() winapi function. Note the DT_HIDEPREFIX option, explicitly dedicated to controlling the behavior of strings containing the & glyph. Not an accident, accurately underlining a single character is ridiculously difficult if you have to do it yourself.
Beyond zalgo there's not that much to worry about. Control characters can be a bit flaky, like "\t" and "\n", you never really use them by accident. And above all, if there's an accident then you'll see it rather quickly :)

How to display unicode for "micron" or lower case "Mu" in a CEdit?

How to display unicode for "micron" or lower case "Mu" in a CEdit?
thx
CEdit *ed = new CEdit();
ed->Create(WS_VISIBLE | WS_BORDER, CRect(200,100,300,120), this, 10);
CString s;
s.Format("%c", xx); //<--- how to do unicode here?
ed->SetWindowText(s);
I think the unicodes:
micron 0x00b5
squared 0x00b2
cubed 0x00b3
degree 0x00b0
If you're using the UNICODE project setting, this is trivial:
s.Format("%c", 0x3BC);
The CString will contain wide (UTF-16) characters which can hold most common Unicode characters in a single location; the only problem will come with Unicode code points over U+FFFF.

Resources