AutoHotkey Community

It is currently May 27th, 2012, 4:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 27th, 2010, 3:54 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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...

Image
Image


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 June 23rd, 2011, 1:17 am, edited 11 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 5:17 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
Very cool, thank you!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 4:54 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You could drag text in- and between edit controls. Most of the useful messages are also described there.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 10:31 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2010, 2:03 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
v0.2 (Preview)
Minor updates. See the bottom of the first post for a list of changes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2010, 2:32 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2010, 3:28 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2010, 5:08 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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 :wink: substitutes. I'll try to rewrite this section to avoid confusion. Thank you for your feedback. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2010, 3:06 pm 
Offline

Joined: March 20th, 2010, 9:49 am
Posts: 224
Quote:
[Library] Edit v1.0 - Update/Control any Edit control


thx a lot man


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2010, 4:19 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Excellent :twisted:

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2010, 3:33 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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:
  1. 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.
  2. 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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2010, 6:05 am 
Offline

Joined: June 7th, 2008, 6:00 am
Posts: 389
I can't believe I've missed this up until this point!

Thank you for your hard work, jballi. It is much appreciated!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2010, 1:17 am 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2010, 2:17 pm 
Offline

Joined: January 8th, 2007, 1:14 pm
Posts: 83
This is exactly what i was looking for, lo and behold, someone had already made it! :)

Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2010, 12:29 pm 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group