Using Unicode characters with Delphi XE2 - delphi

I'm looking at converting one of our applications to Delphi XE2 and generally take the opportunity to bring it up to date.
One of the features of the application is a StringGrid that displays a number of check marks in a couple of columns. To achieve this the grid is actually 2 aligned grids - the second of which is setup with the font as Wingdings in order to display the check marks.
Am I wrong in thinking that I should be able to use something like a TListView and use the checkmark char (U+2713) alongside the rest of the text... If so how the heck do I do this?
Do I need to set the font to Wingdings for that column? Does this need to be in OnDraw?
Am I barking up the wrong tree...

File->New->VCL Forms application
In the Component Palette, expand the Win32 tab and choose TListView, and drop it on the form.
Right-click the newly added TreeView1, and choose Items Editor... from the context menu.
Click New Item. Type in any text (for instance x Testing, using the 'x' as a placeholder for now).
Start the Windows Character Map application (Start button, type Chara in the search box, or Start->Programs->Accessories->Character Map). Change the font to Arial Unicode MS, and navigate to the character you want (it's in there).
Click the character, and then the Copy button. Switch back to the IDE, select the x placeholder you put in the edit, and hit Ctrl+V to paste the character you just chose from Character Map. You should now see your check mark (or whatever character you chose), followed by Testing.
(The steps above are the two-minute process I followed to find out how to do this, and that quick experiment showed that you could.)

Related

Issue with Delphi Menu

I am Using RAD Studio 2010 and I have problem in Menu text
There are Z and Y texts in my menu and I want to remove it
This will happen when I use Non English text
This is because of TMainMenu.AutoHotkeys. By default, the value of this property is maAutomatic, which means that the menu will automatically choose accelerator keys for your menu items.
For instance, in a typical English application, you might get a menu like this:
Notice the underlined characters. These are used to access the menu using the keyboard. For instance, to open the File menu, I can press Alt+F. And once the File menu is open, I can press the key corresponding to the underlined character in the caption of the menu item I wish to invoke.
For keyboard users like myself, such accelerators are extremely important. I use them all the time. I could use the mouse instead, but that would slow me down tremendously. (For instance, in the application in the screenshot, I am very used to press Alt+E, O to open the Sort Lines dialog box. That takes about 0.2 seconds. If I had to use the mouse, it would take much longer!)
Now, in your case, there aren't any Latin letters to underline, so instead the RTL adds these parentheses (with the Latin letter being the accelerator), so you still can access the menus using the keyboard.
I have very little experience with non-Latin-based versions of Windows, but I do believe menus like these are standard. If I were a Chinese or Arabic user (for instance), I think I would refuse to use an application without these. If I cannot access GUI menus and controls with the keyboard, I get really annoyed.
Still, if you insist, you can set AutoHotkeys to maManual.

Aligning left and right on the same line in WordPad

Is it possible to align texts left and right on the same line in WordPad? For example, I want my name to the left and the date to the right. Both on the same line. How can I do this?
While WordPad does not allow you to modify the alignment of tab stops the RTF format supports tab stops with alignments and WordPad can display and edit documents containing such tab stops, for example when you create them in Microsoft Word and save as RTF.
If you don't have access to Microsoft Word you can create the tab stops in WordPad, save the file as RTF, then open it with a text editor and modify the tab stop definitions you are interested in.
Here is an example:
I created a simple RTF document in WordPad which contains the text Left<tab>Middle<tab>Right and created two tab stops. I want the first tab stop to align centered and the second tab stop to align right.
Then I save the document in RTF format on my desktop and open it in notepad. It looks like this:
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 10.0.14393}\viewkind4\uc1
\pard\sa200\sl276\slmult1\tx3976\tx7242\f0\fs22\lang7 Left\tab Middle\tab Right\par
}
Notice the \tx3976 and \tx7242 commands which define the tab stop positions (generally you look for \tx followed by some number).
Now you can insert the \tqc command for center-aligned tabstops or the \tqr command for right-aligned tabstops. You enter that command in front of the \tx command you want to modify. The RTF document now looks like this:
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 10.0.14393}\viewkind4\uc1
\pard\sa200\sl276\slmult1\tqc\tx3976\tqr\tx7242\f0\fs22\lang7 Left\tab Middle\tab Right\par
}
Now you can save the document and exit notepad, when you reopen the file in WordPad you should see it displaying with the correct tab stop alignments. It is also possible to move the tab stops around in WordPad without losing the alignments.
Tested on Windows 10 but it probably will work on earlier versions of WordPad since the required commands are not exactly new.
It's not possible using proper formatting.
For example, in Microsoft Word/LibreOffice Writer you'd use left- and right-aligning tabs, as demonstrated in this howto for Word. However, WordPad only has left-aligning tabs.
It is possible to fake it, as it was done in the old days (and still now, by those who don't know better), by clever usage of spaces (or a mix of spaces and tab stops).

Simple way to avoid TListView items clipping and replace with ellipsis

I have a TListView in vsSmallIcon mode. If I populate it with 2 items and first item text is longer than second item text it will draw first item over the second.
Is there a quick way to replace longer items with ellipsis? Or a complicated one?
I am using Delphi 2010 and C++ Builder 2010 with default settings of TListView
How it looks:
How I want it to look:
Edit: After trying out vsList style I discovered that the above is no longer an issue and it works without any additional code (no ellipsis but no items clipped also).
When working with TListView I often find myself investigating and mimicking the behavior of Windows Explorer.
Regarding your question with ellipsis in vsSmallIcon mode I checked out Explorer. I observed that when I resize the window there’s no ellipsis drawn for item captions. Instead the items are rearranged instantaneously. My suggestion would be to skip the ellipsis strategy because Microsoft has not implemented Explorer that way and chances of a quick fix for you decrease. If you can settle for rearranging then the two following “quick” alternatives should do the job, at least in XE3.
Alt 1:
ListView1.IconOptions.AutoArrange := true;
Alt 2: (must be called explicitly every time you desire a rearrangement):
ListView1.Arrange(arDefault);
Update:
I fired up Delphi 2006 and can confirm that the above methods work there as well

Does RubyMine have TextMate-style multiple line editing?

Is there a shortcut key for editing multiple lines in RubyMine (Windows) as you can do with TextMate? I've seen it in TextMate where you can highlight multiple lines, and press a key code, then start typing. All text you type will appear at the end of all of the highlighted lines. I would love to do this with RubyMine as well.
Thanks!
Yes, this feature is called Column Mode and can be enabled via Edit menu or keyboard shortcut.
RubyMine version 6.3 and later has real multiple line editing. Simultaneously edited areas of text need not be vertically adjacent and vertically aligned (as they must be to use Column Selection Mode).
Briefly,
option-click (on Mac; alt-click on Windows or Linux) to create additional carets, edit as usual, then hit escape to revert to a single caret
select some text and control-G (on Mac; alt-J on Linux and Windows) to search for the next occurrence of that text and add a caret to it
There are also editor commands to add carets (Clone Caret Below, Clone Caret Above) that are not bound by default, but that you can bind to keys of your choice.
More here: What’s Mining: Multiple Cursors and Selection
(Column Selection Mode still works fine for areas of text that are vertically adjacent and aligned.)

Editor to select text that is inside a rectangle

Often I find myself with some text where I want to exclude a certain part of the text, say the first three characters of 40 lines. The fastest way I could think of to do this would be to draw a rectangle and copy the text. I am mostly using Windows, but I am sure grep or something similar could do this with a tiny bit of code. My best way of doing this is to open Command Prompt. Then run "Edit" (yes the good old one). Then paste the text in there (this actually takes a significant amount of time). Then I am able to select the rectangle I am after.
Is there any other editors that support this feature? I am familiar with Notepad++.
You can select a rectangular area to cut/copy in Visual Studio be pressing the Alt key prior to making your selection with the mouse or (Shift +) cursor keys. See How to: Select and Change Text.
The Zeus editor can do keyboard driven column cut/copy and paste.
Also the default Zeus mouse marking is in column mode.
If you use Vim, Ctrl + V will let you select a rectangular block of text.
The documentation says Ctrl + Q will let you do a rectangular select in mswin compatibility.
Emacs supports kill-rectangle (bound to C-x r k by default) and yank-rectagle (C-x r y) to achieve this. Also of possible interest is delete-extract-rectangle (no default binding, and intended for programming use).
You use it by navigating to one corner of the interesting area, hitting C-<space> to set the mark, navigating to the opposite corner, and invoking the desired function.
UltraEdit has a column mode (menu Column/Column Mode, keyboard
shortcut Alt + C). This makes it possible to make block selections, delete, insert column-wise, etc. using only the keyboard (the mouse works too).
For your example: make a zero width selection at column position 1 for the 40 lines and press Delete three times. Or simply make the 3 x 40 block select and press Delete.
You can do this with NEdit (which is available for Windows). Hold down Ctrl and drag the mouse (left-click) to select rectangles.
In Linux, you could also just use cut:
cut -b4- file
It will remove the first three characters from every line and print the result to standard output.
jEdit supports vertical selections (keyboard shortcut is Alt + \). It can also do multiple, non-continuous selections (keyboard shortcut is Ctrl + \). And when you type it affects all selections, so you can edit multiple lines at the same time, or the same line in more than place simultaneously. Or both.
Vertical pasting is also supported. This is a feature I use all the time. It makes editing columns a breeze.
If you have too many lines to select easily, then jEdit's Find And Replace is as good as it gets.
jEdit is a Java application, and so uses more system resources than most editors. But on the other hand it works on most systems, and it has loads of plug-ins to make editing text more efficient.
This can be done using JGSoft's Editpad which has a freeware lite version that is not crippled.
In IntelliJ, go to Edit and then click on Column Selection Mode. Or use the ALT+SHIFT+INSERT shortcut.

Resources