# Edit [v1.1]

作者: jballi 最近更新时间: 20100524

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.

Edit_CanUndo(hEdit)
Edit_CharFromPos(hEdit,X,Y,ByRef r_CharPos="",ByRef r_LineIdx="")
Edit_Clear(hEdit)
Edit_Convert2DOS(p_Text)
Edit_Convert2Mac(p_Text)
Edit_Convert2Unix(p_Text)
Edit_ConvertCase(hEdit,p_Case)
Edit_Copy(hEdit)
Edit_Cut(hEdit)
Edit_EmptyUndoBuffer(hEdit)
Edit_FindText(hEdit,p_SearchText,p_Min=0,p_Max=-1,p_Flags="",ByRef r_RegExOut="")
Edit_FindTextReset()
Edit_FmtLines(hEdit,p_Flag)
Edit_GetActiveHandles(ByRef hEdit="",ByRef hWindow="",p_MsgBox=False)
Edit_GetFirstVisibleLine(hEdit)
Edit_GetLastVisibleLine(hEdit)
Edit_GetLimitText(hEdit)
Edit_GetLine(hEdit,p_LineIdx=-1,p_Length=-1)
Edit_GetLineCount(hEdit)
Edit_GetMargins(hEdit,ByRef r_LeftMargin="",ByRef r_RightMargin="")
Edit_GetModify(hEdit)
Edit_GetRect(hEdit,Left,Top,Right,Bottom)
Edit_GetSel(hEdit,l_StartSelPos,l_EndSelPos)
Edit_GetSelText(hEdit)
Edit_GetText(hEdit,p_Length=-1)
Edit_GetTextLength(hEdit)
Edit_GetTextRange(hEdit,p_Min=0,p_Max=-1)
Edit_IsMultiline(hEdit)
Edit_IsReadOnly(hEdit)
Edit_IsStyle(hEdit,p_Style)
Edit_LineFromChar(hEdit,p_CharPos=-1)
Edit_LineFromPos(hEdit,X,Y,ByRef r_CharPos="",ByRef r_LineIdx="")
Edit_LineIndex(hedit,p_LineIdx=-1)
Edit_LineLength(hEdit,p_LineIdx=-1)
Edit_LineScroll(hEdit,xScroll=0,yScroll=0)
Edit_LoadFile(hEdit,p_FileName,p_Convert2DOS=False,ByRef r_FileFormat="")
Edit_Paste(hEdit)
Edit_PosFromChar(hEdit,p_CharPos,ByRef X,ByRef Y)
Edit_ReplaceSel(hEdit,l_SelectedText)
Edit_SaveFile(hEdit,p_FileName,p_Convert="")
Edit_Scroll(hEdit,p_Pages=0,p_Lines=0)
Edit_ScrollCaret(hEdit)
Edit_SetLimitText(hEdit,p_Limit)
Edit_SetMargins(hEdit,p_LeftMargin="",p_RightMargin="")
Edit_SetModify(hEdit,p_Flag)
Edit_SetPasswordChar(hEdit,p_Char="*")
Edit_SetReadOnly(hEdit,p_Flag)
Edit_SetRect(hEdit,p_Left,p_Top,p_Right,p_Bottom)
Edit_SetSel(hEdit,l_StartSelPos,l_EndSelPos)
Edit_SetStyle(hEdit,p_Style,p_Option="+")
Edit_SetTabStops(hEdit,p_NbrOfTabStops=0,p_DTU=32)
Edit_SetText(hEdit,p_Text)
Edit_TextIsSelected(hEdit)
Edit_Undo(hEdit)

关于函数的参数和返回值, 请参阅其源码或 此文档.

#### 备注

The Add-Ons for this library are not included. The downloadable archive from forum contains all files. There are more comprehensive example scripts.

关于此函数(集)的更新细节和注意事项, 请参见 AutoHotkey 论坛: http://www.autohotkey.com/forum/viewtopic.php?t=55062

#### 许可

不存在

#### 示例

    ; #Include Edit.ahk
    #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir%

    ; Start Notepad and get handle of the editor.
    Run, notepad.exe,, , pid
    WinWait ahk_pid %pid%
    ControlGet, hEdit, Hwnd,, Edit1, ahk_pid %pid%

    ; Set default text to opened editor.
    GoSub, F1

    ; Exit script after attached Notepad is closed.
    WinWaitClose, ahk_pid %pid%
    ExitApp

    ; Hotkeys for testing on that editor.
    F1::Edit_SetText( hEdit, "Hotkeys `r`n  F1 - Set editor to default text`r`n  F2 - Show length of text`r`n  F3 - search text ""Show"", ahk_pid %pid%" )
    F2::MsgBox % "Text length: " . Edit_GetTextLength( hEdit )
    F3::MsgBox % "Position of ""Show"": " . Edit_FindText( hEdit,  "Show")