| View previous topic :: View next topic |
| Author |
Message |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sat Feb 27, 2010 2:54 am Post subject: [Library] Edit v1.1 - Update/Control any Edit control |
|
|
Introduction
Although not as robust as the Rich Edit control, the standard Edit control is a lightweight and surprisingly powerful control for managing text. Inspired by the Edit mini-library created by Lexikos and the HiEditor library created by majkinetor, the Edit library was created to help bring the Edit control out of it's inferiority shell.
Screenshots
A couple of screenshots from the examples...
The Code
The pertinent files are as follows:
Issues/Considerations
- Examples. Most of the example scripts can make real changes to real data. Use care when running these scripts.
- Documentation. It's getting better but I'm a still a Natural Docs newbie. It's going to take a little while for me to adjust to the Natural Docs style.
References
The following posts were helpful in the creation of this library. Thanks to the original authors.
Scripts that use the Edit library:
---------------------------------------------------------------------------
Release Notes
v0.1 (Preview)
Original release.
v0.2 (Preview)
- The Edit_CharFromPos function has been rewritten to support controls with more than 65,536 characters and/or more than 65,536 lines of text.
- Added Drag & Drop example (thanks Laszlo)
v1.0
- Removed Edit_GetThumb function. Could not get the EM_GETTHUMB message to work on an Edit control. Most documentation implies that the message is for the RichEdit control.
v1.1
- Fix: Edit_Edit_PosFromChar function modified to correctly return a negative number if the requested character is outside the edit control.
- Added the Edit_TTSGUI (Preview) add-on function to show a Text-To-Speech player for any edit control. Includes a plethora of options. Requires the COM library.
- Added the Edit_SpellCheckGUI (Preview) add-on function. Requires the Spell library.
- Updated examples.
Last edited by jballi on Thu Jun 23, 2011 12:17 am; edited 11 times in total |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 181
|
Posted: Sat Feb 27, 2010 4:17 am Post subject: |
|
|
| Very cool, thank you! |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Sat Feb 27, 2010 3:54 pm Post subject: |
|
|
| You could drag text in- and between edit controls. Most of the useful messages are also described there. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sun Feb 28, 2010 9:31 am Post subject: |
|
|
| Laszlo wrote: | | You could drag text in- and between edit controls. Most of the useful messages are also described there. |
Sound cool. I'll check it out. Thanks.  |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sat Mar 06, 2010 1:03 am Post subject: |
|
|
v0.2 (Preview)
Minor updates. See the bottom of the first post for a list of changes. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sun Apr 11, 2010 1:32 am Post subject: |
|
|
v1.0
Superficial changes only. No need to download if you have v0.2 already. See the bottom of the first post for a list of changes. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Sun Apr 11, 2010 2:28 am Post subject: |
|
|
Well done.
| jballi wrote: | | Missing messages include EM_GETSELTEXT, EM_GETTEXTRANGE, and EM_FINDTEXT. ... Although the substitute code/messages are very capable, they are not quite as efficient (memory and/or speed) as the messages they replace (if they existed). | FYI, MSDN explicitly states these messages are for rich edit controls. They're not supposed to work for edit controls. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sun Apr 11, 2010 4:08 am Post subject: |
|
|
| Lexikos wrote: | | jballi wrote: | | Missing messages include EM_GETSELTEXT, EM_GETTEXTRANGE, and EM_FINDTEXT. ... Although the substitute code/messages are very capable, they are not quite as efficient (memory and/or speed) as the messages they replace (if they existed). | FYI, MSDN explicitly states these messages are for rich edit controls. They're not supposed to work for edit controls. |
Of course. I was just trying to get across that these messages are needed for the Edit control and that the library provides fantabulous substitutes. I'll try to rewrite this section to avoid confusion. Thank you for your feedback.  |
|
| Back to top |
|
 |
XYZ
Joined: 20 Mar 2010 Posts: 224
|
Posted: Sun Apr 11, 2010 2:06 pm Post subject: |
|
|
| Quote: |
[Library] Edit v1.0 - Update/Control any Edit control
|
thx a lot man |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sun May 23, 2010 2:33 am Post subject: |
|
|
Smart Word Wrap Toggle For Notepad
One of the problems (read: pet peeves) with toggling Word Wrap in Notepad is that the program loses track of where you were in the document. It's not a big deal if you just opened the document or if you're working on the first few lines, but if you were working far into the document, it can be very irritating.
This script provide two basic features:
- Context-sensitive hotkey. This code will only fire if a Notepad window is active. Uses Ctrl+W (patterned after PSPad) but change it to whatever you want.
- Preserve caret position or selection. If typing just before the hotkey is used, you can resume typing immediately afterwards. If text was selected before the hotkey is used, the same text will be selected afterwards.
Here's the code (needs the Edit library of course):
| Code: | ;[=============]
;[ Ctrl+W ]
;[ [Notepad] ]
;[=============]
#IfWinActive ahk_class Notepad
^w::
#IfWinActive
;-- Get current handle to the Edit control
if Edit_GetActiveHandles(hEdit)
{
;-- Get current select positions
Edit_GetSel(hEdit,$StartSelPos,$EndSelPos)
;-- Toggle word wrap
SendMessage 0x111,32,0 ;-- 0x111=WM_COMMAND
;-- Collect new handle to the Edit control
Edit_GetActiveHandles(hEdit)
;-- Set caret
Edit_SetSel(hEdit,$StartSelPos,$StartSelPos)
Edit_ScrollCaret(hEdit)
;-- Initial selection and scroll. This makes sure that the leftmost
; position of the selection is showing.
;-- Re-select if necessary
if ($StartSelPos<>$EndSelPos)
{
Edit_SetSel(hEdit,$StartSelPos,$EndSelPos)
;-- Show as much of the selection as possible
$FirstVisibleLine :=Edit_GetFirstVisibleLine(hEdit)
$LastVisibleLine :=Edit_GetLastVisibleLine(hEdit)
$FirstSelectedLine:=Edit_LineFromChar(hEdit,$StartSelPos)
$LastSelectedLine :=Edit_LineFromChar(hEdit,$EndSelPos)
;-- Last line showing?
if ($LastSelectedLine>$LastVisibleLine)
if ($LastSelectedLine-$LastVisibleLine<$FirstSelectedLine-$FirstVisibleLine)
Edit_LineScroll(hEdit,0,($LastVisibleLine-$LastSelectedLine)*-1)
else
Edit_LineScroll(hEdit,0,($FirstVisibleLine-$FirstSelectedLine)*-1)
}
}
return
|
I hope that someone finds this useful. |
|
| Back to top |
|
 |
Wicked
Joined: 07 Jun 2008 Posts: 369
|
Posted: Sun May 23, 2010 5:05 am Post subject: |
|
|
I can't believe I've missed this up until this point!
Thank you for your hard work, jballi. It is much appreciated! |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Mon May 24, 2010 12:17 am Post subject: |
|
|
v1.1
Minor bug fix plus a couple of new add-on functions. See the bottom of the first post for a list of changes. |
|
| Back to top |
|
 |
Mystiq
Joined: 08 Jan 2007 Posts: 83
|
Posted: Wed Aug 25, 2010 1:17 pm Post subject: |
|
|
This is exactly what i was looking for, lo and behold, someone had already made it!
Thanks! |
|
| Back to top |
|
 |
tov Guest
|
Posted: Fri Dec 03, 2010 11:29 am Post subject: |
|
|
Looks looks great
I need my edit box to only hold 1000 lines of text, after that I want the top line to be removed and everything else scroll up.
The edit box is being constantly updated by a live stream, using 1000 lines will reduce the memory overhead needed.
I will have a play.. but : Can anyone point me in the right direction ??
Thanks |
|
| Back to top |
|
 |
|