How to deteriminate max string length in on line in edit box in Lazarus - lazarus

I was wondering how can i make that when user input longer string than box's width cursor goes to a new line and when there is more text that can fit into editbox, showbar shows itself and user can input 'infinite' lenght string?

Related

How to create multi line text field with vertical scrollbar enabled in openedge progress 4gl?

I have a database column called user_notes. This column length is 4000 char. this column having records in multi line.
Now I want to display this column value in progress form. I have tried the method mentioned in the reference URL Progress display long field (frame/form)
But scrollbar not enabled for the field. can anyone advice how to enable vertical scrollbar for long text item field.
Use an editor widget. It does word wrapping and has a vertical scrollbar.
DEFINE VARIABLE Editor-1 AS CHARACTER
VIEW-AS EDITOR SCROLLBAR-VERTICAL
SIZE 34 BY 8 NO-UNDO.
Editor-1 = "Test text".
DEFINE VARIABLE wWindow AS WIDGET-HANDLE NO-UNDO.
DEFINE FRAME fFrame
Editor-1 AT ROW 2 COL 4 NO-LABEL
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 40 BY 10.
CREATE WINDOW wWindow ASSIGN
HEIGHT = 10
WIDTH = 40
SENSITIVE = yes
HIDDEN = no.
DISPLAY Editor-1 WITH FRAME fFrame IN WINDOW wWindow.
ENABLE Editor-1 WITH FRAME fFrame IN WINDOW wWindow.
VIEW wWindow.
WAIT-FOR CLOSE OF THIS-PROCEDURE.
Add the READ-ONLY option to disallow data entry.

optimalfill of a label

I have two forms in my application, form1 sending a long string (more than 300 characters) or short string (less than 50 characthers) to a label on form2 with a click of a button, I'm using a label because I can't find a memo component with transparent background, and Canvas stuff requires a long code compared with the label properties.
Some label properties
Align == alClient
Alignment = taCenter
Layout = tlCenter
WordWrap = True
AutoSize = True
OptimalFill = True
The idea is to adjust the height of the text with OptimalFill, but when I send a long string to the label, the font size, goes all wrong, sometimes the label fills right (when I repeat a long string after a short string for example).
With a:
showMessage(IntToStr(label.Font.Size));
I've got some weird changes on the font size, if I send a string with 100 chars for the first time I got a font like 18, if I send a string with 20 I got a font like 30 and if I send the same string with 100 chars, I got a 22 (numbers are just an example, not the real / right ones), and not even what they should be btw
IF I change the Caption, the text height goes bad (still the font size of the first string that I've used), it only changes when I send a small string, things just go strange.
Following the above example will be something like:
string with 100 chars returns a font size of 20
string with 70 chars returns a font size of 20 //should be arround 25 or so
string with 10 chars returns a font size of 40
string with 100 chars returns a font size of 22
Already tried:
// to 'reset' the font size then put the string on the caption and later the real string
Caption: = '';
Caption: = # 0;
Caption: = ' ';
Caption: = '-';
Label.Update; // to update the 'math'
Label.Refresh; // to update the 'math'
Label.Repaint; //one by one and all togheter
Label.AdjustSize
Application.ProcessMessages
Form2.Update
Label.UpdateBaseBound
Labe.AdjustFontForOptimalFill;
I tried after and before the 'on click sent string to'
label.Caption: = stringGrid.Cells [0, stringGrid.Row];
Also tried enable and disable the label to 'reset' everything.
Nothing works right, things have a strange value (font size) and the font size depends on the length of the sequence.
How can I make it work right and create the right source calculation each time Legend changes?
Arch Linux X64 with the latest Lazarus (QT) using Gnome 3.22.3 (not sure if this is relevant)

Multi-line headers for TTabSheet?

I have a TPageControl with several tabs. On one page, the header is a bit too long and appears clipped on a single line. Is it possible to have the tab header be multi-line (ie. like the WordWrap property on buttons)?
In the image below the caption has been set to "This text is too long to fit onto one row". Ideally, this should appear on two rows:
This text is too long to fit
onto one row
For the example below I have set:
TabWidth := 185;
TabHeight := 60;
* EDIT *
The example above does not apply any theme. When a skin is applied (in this case the 3rd party product VCLSkin) and I insert a newline character at runtime, then it works:
Product_Sheet.Caption := (
'This text is too long' + #13#10 + 'to fit onto one row');
Based on the comments below, this suggests that in the absence of a skin, this will need to be custom-drawn.

Sublime text 3 character offset highlighting by numeral range

Is there a way/plugin in sublime text 3 for highlighting multiple character offset ranges? The ideal desired functionality would be something like this: given a range of character offsets (e.g. 200-400, 5000-5300, 6400-6450) highlight the corresponding ranges.
This can be done with a WindowCommand plugin. Go to Tools -> New Plugin... and replace the contents with the following:
import sublime
import sublime_plugin
class SelectRegionCommand(sublime_plugin.WindowCommand):
def highlight_region(self, regions):
region_list = []
if "," in regions:
for region in regions.split(","):
region_list.append(tuple(region.split("-")))
else:
region_list.append(tuple(regions.split("-")))
view = self.window.active_view()
view.show(int(region_list[0][0]))
for region in region_list:
begin = int(region[0])
end = int(region[1])
to_highlight = sublime.Region(begin, end)
view.sel().add(to_highlight)
def run(self):
message = "Enter offset range(s) to select, separated by commas:"
default = "0-100"
self.window.show_input_panel(message, default, self.highlight_region, None, None)
Save the file as Packages/User/select_region.py (it should open that directory automatically), where Packages is the directory opened by selecting Preferences -> Browse Packages....
Next, create a custom key binding to trigger the plugin. Open Preferences -> Key Bindings-User and add the following line:
{ "keys": ["ctrl+alt+shift+s"], "command": "select_region" }
If the file is empty, surround the key binding with square brackets [ ]. Save the file, and you're all set. Hitting CtrlAltShiftS will bring up an input panel at the bottom of the window where you can enter the character offsets. Please don't include any spaces, so your input should look like the following:
Hit Enter, and the regions you entered will be selected:
EDIT
I altered the code slightly so that the view scrolls to the beginning of the first region entered (it should be centered on the screen). If you don't want that functionality for some reason, just comment out the view.show(int(region_list[0][0])) line (line 14).

ZPL - zebra: print justified text block without overwriting last line

I'm using the following command to print a justified text:
^FB1800,3,0,J^FT100,200^A0B,26,26^FH\^FDLONG TEXT TO BE PRINTED, WHICH DOESNT FIT IN ONLY 3 LINES...^FS
The command ^FB1800,3,0,J prints a field block in a width of 1800 dots, maximum 3 lines, justified.
The problem is that if the text exceeds the maximum number of lines, it overwrites the last line! :( That of course makes the text of the last line unreadable.
How can I avoid that? Does anybody know if is there a way to cut the exceeding text?
The documentation says exactly that this happens:
Text exceeding the maximum number of lines overwrites the last line. Changing the font size automatically increases or decreases the size of the block.
For reference: I'm using printer Zebra 220Xi4.
Any help would be appreciated. Thank you!
Take a look at the ^TB command. It is preferred over the ^FB command and truncates if the text exceeds the size defined in the TB params
I had just about the same problem, what fixed it in my case - although not the most elegant way - is to specify a higher number of maximum lines, and then formatting it in a way that only the first 3 are in the visible area.
In your case it would be for example ^FB1800,7,0,J instead of ^FB1800,3,0,J
This at least fixed it for me right away, because I print this text at the bottom of the label. If you need to have it somewhere in the middle or top, there might be some tricks with putting a (white) box on top of the overflow-area, since the Zebra printers seem to render before printing. Hope it helps.
Depending on the higher-level programming language you're using (assuming that you are), you could accomplish the same thing (truncate the text to be printed to a specified number of characters) with code like this (C# shown here):
public void PrintLabel(string price, string description, string barcode)
{
const int MAX_CAPS_DESC_LEN = 21;
const int MAX_LOWERCASE_DESC_LEN = 32;
try
{
bool descAllUpper = HHSUtils.IsAllUpper(description);
if (descAllUpper)
{
if (description.Length > MAX_CAPS_DESC_LEN)
{
description = description.Substring(0, MAX_CAPS_DESC_LEN);
}
}
else // not all upper
{
if (description.Length > MAX_LOWERCASE_DESC_LEN)
{
description = description.Substring(0, MAX_LOWERCASE_DESC_LEN);
}
}
. . .
This is what I'm using; is there any reason to prefer the "raw" ^TB command over this?

Resources