Jump to content

APE


torels
 Share

Recommended Posts

Hi there

I just wrote a simple Autoit Tabbed editor

what do you think about it ?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Programmi\AutoIt3\Icons\filetype2.ico
#AutoIt3Wrapper_outfile=APE.exe
#AutoIt3Wrapper_Res_Comment=APE - AutoIt Portable Editor
#AutoIt3Wrapper_Res_Description=Portable Editor for au3
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=GNU GPL
#AutoIt3Wrapper_Res_File_Add=C:\Programmi\AutoIt3\Aut2Exe\Aut2exe.exe
#AutoIt3Wrapper_Res_File_Add=C:\Programmi\AutoIt3\Aut2Exe\upx.exe
#AutoIt3Wrapper_Res_File_Add=C:\Programmi\AutoIt3\AutoIt3.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Ape Autoit Portable Editor
;Author: torels_
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GuiStatusBar.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>
#include <SendMessage.au3>
#include <GuiTab.au3>
FileInstall(@ProgramFilesDir & "\Autoit3\Aut2Exe\Aut2exe.exe", @TempDir & "\Aut2exe.exe")
FileInstall(@ProgramFilesDir & "\Autoit3\Aut2Exe\upx.exe", @TempDir & "\upx.exe")
FileInstall(@ProgramFilesDir & "\Autoit3\AutoIt3.exe",@TempDir & "\AutoIt3.exe")
FileInstall(@ProgramFilesDir & "\Autoit3\Aut2Exe\AutoitSC.bin",@TempDir & "\AutoItSC.bin")
Dim $File
$GUI = GUICreate("APE - AutoIt Portable Editor", 630, 510, Default, Default, $WS_SIZEBOX + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_SYSMENU)
$FileMenu = GUICtrlCreateMenu("&File")
    $NewMenu = GUICtrlCreateMenuItem("&New..." & @TAB & "Ctrl+N", $FileMenu)
    HotKeySet("^n", "_New")
    $OpenMenu = GUICtrlCreateMenuItem("&Open..." & @TAB & "Ctrl+O", $FileMenu)
    HotKeySet("^o", "_Open")
    $CloseTab = GUICtrlCreateMenuItem("&Close..." & @TAB & "Ctrl+T", $FileMenu)
    HotKeySet("^t", "_CloseTab")
    $SaveMenu = GUICtrlCreateMenuItem("&Save" & @TAB & "Ctrl+S", $FileMenu)
    HotKeySet("^s", "_Save")
    $SaveAsMenu = GUICtrlCreateMenuItem("Save &As..." & @TAB & "Ctrl+M", $FileMenu)
    HotKeySet("^m", "_SaveAs")
$SearchMenu = GUICtrlCreateMenu("&Search")
    $FindMenu = GUICtrlCreateMenuItem("Find..." & @TAB & "Ctrl+F", $SearchMenu)
    HotKeySet("^f", "_Search")
    $RepMenu = GUICtrlCreateMenuItem("Replace" & @TAB & "Ctrl+H", $SearchMenu)
    HotKeySet("^h", "_Replace")
$ToolsMenu = GUICtrlCreateMenu("&Tools")
    $RunMenu = GUICtrlCreateMenuItem("Run" & @TAB & "F5", $ToolsMenu)
    HotKeySet("{F5}", "_ExecuteScript")
    $CompileMenu = GUICtrlCreateMenuItem("Compile" & @TAB & "Ctrl+F7", $ToolsMenu)
    HotKeySet("^{F7}", "_CompileScript")
$HelpMenu = GUICtrlCreateMenu("&Help")
    $Info = GUICtrlCreateMenuItem("Info", $HelpMenu)
    
$MainTab = _GUICtrlTab_Create($GUI, 0,0,630, 20, $TCS_FIXEDWIDTH +  $TCS_FORCELABELLEFT)
$LinesEdit = GUICtrlCreateEdit("", 0, 21, 30, 420, $SS_RIGHT + $GUI_SS_DEFAULT_EDIT - $WS_VSCROLL + $ES_READONLY);BitOR($SS_RIGHT, $SS_RIGHTJUST, $SS_SUNKEN))
GUICtrlSetResizing($LinesEdit, $GUI_DOCKWIDTH + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
GUICtrlSetBkColor($LinesEdit, 0xDDDDDD)
$Edit = GUICtrlCreateEdit("", 29, 21, 600, 420)
GUICtrlSetResizing($Edit, $GUI_DOCKRIGHT + $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
$StatusBar = _GUICtrlStatusBar_Create($GUI, Default,"",$SBARS_SIZEGRIP)
GUISetState(@SW_SHOW)

While 1
    $width = ControlGetPos($GUI,"",$MainTab)
    $WinWidth = WinGetPos($GUI)
    If $width[3] < $WinWidth[3] Then
        ControlMove($GUI,"",$MainTab, $width[0], $width[1], $WinWidth[2])
    EndIf
    _update()
    Switch GUIGetMsg()
        Case -3
            FileDelete(@TempDir & "\Aut2exe.exe")
            FileDelete(@TempDir & "\upx.exe")
            FileDelete(@TempDir & "\AutoIt3.exe")
            Exit
        Case $RunMenu
            _ExecuteScript()
        Case $CompileMenu
            _CompileScript()
        Case $OpenMenu
            _Open()
        Case $CloseTab
            _CloseTab()
        Case $SaveAsMenu
            _SaveAs()
        Case $SaveMenu
            _Save()
        Case $NewMenu
            _New()
        Case $FindMenu
            _Search()
        Case $RepMenu
            _Replace()
        Case $Info
            MsgBox(64, "Info - APE", "APE v1.0 by torels_" & @CRLF & _
            "APE - AutoIt Portable Editor released under GNU GPL Licence" & @CRLF & _
            "For further Info please visit http://torels.altervista.org or email gab.torels@gmail.com")
    EndSwitch
    _GUICtrlStatusBar_Resize($StatusBar)
WEnd

Func _update()
    ;---- Lines
    $Lines = _GUICtrlEdit_GetLineCount($LinesEdit)
    $ActualLines = _GUICtrlEdit_GetLineCount($Edit)
    If $ActualLines<>($Lines - 1) Then
        _GUICtrlEdit_BeginUpdate($LinesEdit)
        _GUICtrlEdit_SetText($LinesEdit, "")
        For $i = 1 to $ActualLines
            _GUICtrlEdit_AppendText($LinesEdit, $i & @CRLF)
        Next
        _GUICtrlEdit_EndUpdate($LinesEdit)
    EndIf
    $EditPos = _GUICtrlEdit_GetFirstVisibleLine($Edit)
    $LinePos = _GUICtrlEdit_GetFirstVisibleLine($LinesEdit)
    $index = StringInStr(_GUICtrlEdit_GetText($LinesEdit), $EditPos)
    If $EditPos<>$LinePos Then 
        _SendMessage(GUICtrlGetHandle($LinesEdit),$EM_LINESCROLL,0,_GUICtrlEdit_GetFirstVisibleLine($Edit)-_GUICtrlEdit_GetFirstVisibleLine($LinesEdit))
    EndIf
    ;---- Lines -> END
    
    ;---- Active File
    $ActiveTab = _GUICtrlTab_GetItemText($MainTab, _GUICtrlTab_GetCurSel($MainTab))
    If _GUICtrlStatusBar_GetText($StatusBar, 0) <> $ActiveTab Then
        ;MsgBox(0,"",$ActiveTab)
        _GUICtrlEdit_SetText($Edit, FileRead($ActiveTab))
        $Split = StringSplit($ActiveTab, "\")
        WinSetTitle($GUI,"", $Split[UBound($split) - 1] & " - APE")
        _GUICtrlStatusBar_SetText($StatusBar, $ActiveTab)
    EndIf
    ;---- Active File -> END
EndFunc

Func _CloseTab()
    If WinActive($GUI) Then
        If _GUICtrlTab_GetItemCount($MainTab) > 1 then 
            $sel = _GUICtrlTab_GetCurSel($MainTab)
            _GUICtrlTab_DeleteItem($MainTab, $sel)
            _GUICtrlTab_SetCurSel($MainTab, $sel)
            If _GUICtrlTab_GetCurSel($MainTab) = -1 Then _GUICtrlTab_SetCurSel($MainTab, $sel -  1)
        EndIf
    EndIf
EndFunc

Func _Open($File = "")
    If WinActive($GUI) Then
        If $File = "" Then $File = FileOpenDialog("Open au3 script", @DesktopDir, "au3 (*.au3)")
        If not @error Then
            $read = FileRead($File)
            _GUICtrlTab_InsertItem($MainTab, _GUICtrlTab_GetItemCount($MainTab), $File)
            _GUICtrlStatusBar_SetText($StatusBar, $File)
            $Split = StringSplit($File, "\")
            WinSetTitle($GUI,"", $Split[UBound($split) - 1] & " - APE")
            _GUICtrlEdit_SetText($Edit, FileRead($File))
        EndIf
    EndIf
EndFunc

Func _New()
    If WinActive($GUI) Then
        $FileName = @TempDir & "\New File " & Floor(Random(0,101))
        $File = FileClose(FileOpen($FileName, 2))
        If not @error Then
            $read = FileRead($File)
            _GUICtrlTab_InsertItem($MainTab, _GUICtrlTab_GetItemCount($MainTab), $File)
            _GUICtrlStatusBar_SetText($StatusBar, $File)
            $Split = StringSplit($FileName, "\")
            WinSetTitle($GUI,"", $Split[UBound($split) - 1] & " - APE")
            _GUICtrlEdit_SetText($Edit, FileRead($File))
        EndIf
    EndIf
EndFunc

Func _Save()
    If WinActive($GUI) Then
        $read = _GUICtrlEdit_GetText($Edit)
        $File = FileOpen(_GUICtrlStatusBar_GetText($StatusBar, 0),2)
        FileWrite($File, $read)
        FileClose($File)
    EndIf
EndFunc

Func _SaveAs()
    If WinActive($GUI) Then
        $File = FileSaveDialog("Save File As...", @DesktopDir, "au3 files (*.au3)")
        If not @error Then
            $read = _GUICtrlEdit_GetText($Edit)
            $File = FileOpen($File,2)
            FileWrite($File, $read)
            FileClose($File)
        EndIf
    EndIf
EndFunc

Func _ExecuteScript()
    If WinActive($GUI) Then
        _Save()
        Run(@TempDir & '\AutoIt3.exe "' & _GUICtrlStatusBar_GetText($StatusBar, 0) & '"', @TempDir)
    EndIf
EndFunc

Func _CompileScript()
    If WinActive($GUI) Then
        Run(@TempDir & '\Aut2exe.exe')
    EndIf
EndFunc

Func _Search()
    If WinActive($GUI) Then
        $text = _GUICtrlEdit_Find($Edit)
    EndIf
EndFunc

Func _Replace()
    If WinActive($GUI) Then
        $Find = InputBox("Replace", "Find", Default, Default,Default,100)
        If $Find <> "" and not @error Then 
            $Replace = InputBox("Replace With", "Replace With...",Default, Default,Default,100)
            $text = _GUICtrlEdit_GetText($Edit)
            _GUICtrlEdit_SetText($Edit, StringReplace($text, $Find, $Replace))
        EndIf
    EndIf
EndFunc

Comments are welcome :P

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

The tabs are also broken on Vista (maybe XP). Try this -

enter text

create a new tab

The text is erased. Now create a few more tabs and enter some text. The text is displayed on all the tabs. Removing tabs doesn't do much either. Also resizing will leave the bottom status bar floating on the screen until the user releases the mouse button.

Link to comment
Share on other sites

I tried syntax highliting

but don't manage to get it with rtf control... it gets far to much cpu

yes I forgot to add the bin file

@wraithdu the statusbar is normal... I think script "pauses" when win moves or resizes :P

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Infact it was meant for Computers WITHOUT autoit installed

it's a fortune editor

anyway... I'll work on the highliting

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...