Sign in to follow this  
Followers 0
Nologic

GenericVCS User Tool

1 post in this topic

#1 ·  Posted (edited)

I made a tool (IDM forum) for use with my favorite text editor...UltraEdit...the reason was simple enough...it doesn't support any sort of VCS (vesion control system) out of the box...so I set out to do something about it.

Rough example INI's are done up for Git, Mercurial, SVN, but others can be added.

This should be fairly easy to get working with other text editors...and hopefully it'll inspire someone to write something better. :)

Link to File: Linky   (MediaFire)

Command Line:

GenericVCS.exe "<VCS_File.ini>" "<Active_File.Ext>"

INI Format:

[<Label>]
Icon=<PathToIcon>
DIR="<PathToToolIfNeeded>"
CMD=<CommandLineOfTool>
Input=<TextForModifyValueInCMD>

Actual AutoIt Code:

#include <Array.au3>

#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GUIButton.au3>
#include <GUIConstantsEx.au3>
#include <GUIImageList.au3>

; Command Line Augments
;------------------------------
; .\GenericVCS.exe "<VCS_File.ini>" "<Active_File.Ext>"

If $CmdLine[0] <> 2 Then Exit
If NOT FileExists( $CmdLine[1] ) Then Exit
If NOT FileExists( $CmdLine[2] ) Then Exit

; String Reference
;------------------------------
; %f       = Full Path to File
; %p       = Directory Path to File
; %n       = File Name Minus Extension
; %e       = File Extension
; %modify% = Prompt for User Input

$aMyINI = IniReadSectionNames( $CmdLine[1] )
If IsArray( $aMyINI ) <> 1 Then Exit

; Fill 2D Array
Dim $aMyButtonArray[$aMyINI[0] + 1][6] = [[$aMyINI[0]]]
For $ii = 1 To $aMyINI[0]
    $aSection = IniReadSection( $CmdLine[1] , $aMyINI[$ii] )
    $aMyButtonArray[$ii][0] = $aMyINI[$ii]
    $aMyButtonArray[$ii][1] = _IniArrayCheck( $aSection , 'Icon' )
    $aMyButtonArray[$ii][2] = _IniArrayCheck( $aSection , 'DIR'  )
    $aMyButtonArray[$ii][3] = _IniArrayCheck( $aSection , 'CMD'  )
    $aMyButtonArray[$ii][4] = _IniArrayCheck( $aSection , 'Input')
Next

#Region ### START Koda GUI section ###
$iButtonHeight = 0
$iFormHeight = 25 * $aMyINI[0]
$iSetButtonSizeW = 25
$aMyMouse = MouseGetPos()
$Form = GUICreate('', 200, $iFormHeight, $aMyMouse[0] - 10 , $aMyMouse[1] - 10 , $WS_POPUP, 0)
; Populate Form
For $ii = 1 To $aMyINI[0]
    $aMyButtonArray[$ii][5] = GUICtrlCreateButton($aMyINI[$ii], 0, $iButtonHeight, $iSetButtonSizeW, 25, $BS_LEFT)
    If StringInStr( $aMyButtonArray[$ii][1] , '.\' ) Then $aMyButtonArray[$ii][1] = StringReplace( $aMyButtonArray[$ii][1] , '.\' , @ScriptDir & '\' )
    If FileExists($aMyButtonArray[$ii][1]) Then
        _GUICtrlButton_SetImage( $aMyButtonArray[$ii][5] , $aMyButtonArray[$ii][1] )
    Else
        _GUICtrlButton_SetImage( $aMyButtonArray[$ii][5] , @ScriptDir & '\Icons\blank.ico' )
    EndIf
    $aGetButtonSize = _GUICtrlButton_GetIdealSize( $aMyButtonArray[$ii][5] )
    If $aGetButtonSize[0] > $iSetButtonSizeW Then $iSetButtonSizeW = $aGetButtonSize[0]
    $iButtonHeight += 25
Next
; Resize Form
WinMove( $Form , '' , $aMyMouse[0] - 10 , $aMyMouse[1] - 10 , $iSetButtonSizeW , $iFormHeight , 1 )
For $ii = 1 To $aMyButtonArray[0][0]
    _GUICtrlButton_SetSize( $aMyButtonArray[$ii][5] , $iSetButtonSizeW , 25 )
Next
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    For $ii = 1 To $aMyButtonArray[0][0]
        If $nMsg = $aMyButtonArray[$ii][5] Then
            $sFileDir   = StringLeft    ( $CmdLine[2] , StringInStr( $CmdLine[2] , '\' , 0 , -1 ) )
            $sFileExt   = StringTrimLeft( $CmdLine[2] , StringInStr( $CmdLine[2] , '.' , 0 , -1 ) - 1 )
            $sFileName  = StringTrimLeft( $CmdLine[2] , StringInStr( $CmdLine[2] , '\' , 0 , -1 ) )
            $sShortName = StringLeft    ( $sFileName  , StringInStr( $sFileName  , '.' , 0 , -1 ) - 1 )

            $aMyButtonArray[$ii][2] = StringStripWS( $aMyButtonArray[$ii][2] , 3 )
            $aMyButtonArray[$ii][2] = StringReplace( $aMyButtonArray[$ii][2] , '%p' , $sFileDir )

            $aMyButtonArray[$ii][3] = StringStripWS( $aMyButtonArray[$ii][3] , 3 )
            $aMyButtonArray[$ii][3] = StringReplace( $aMyButtonArray[$ii][3] , '%f' , $CmdLine[2] )
            $aMyButtonArray[$ii][3] = StringReplace( $aMyButtonArray[$ii][3] , '%p' , $sFileDir   )
            $aMyButtonArray[$ii][3] = StringReplace( $aMyButtonArray[$ii][3] , '%n' , $sShortName )
            $aMyButtonArray[$ii][3] = StringReplace( $aMyButtonArray[$ii][3] , '%e' , $sFileExt   )

            If StringInStr( $aMyButtonArray[$ii][3] , '%modify%' ) <> 0 Then
                $aMyButtonArray[$ii][4] = StringReplace( $aMyButtonArray[$ii][4] , '\n' , @LF )
                $sAnswer = InputBox( 'User Input Needed' , $aMyButtonArray[$ii][4] )
                $aMyButtonArray[$ii][3] = StringReplace( $aMyButtonArray[$ii][3] , '%modify%' , $sAnswer )
            EndIf

            Run( @ComSpec & ' /c ' & $aMyButtonArray[$ii][3] , $aMyButtonArray[$ii][2] , @SW_HIDE )
            Exit
        EndIf
    Next
    If WinActive( $Form ) = 0 Then Exit
WEnd

Func _IniArrayCheck( ByRef $Array , $String )
    $iFind = _ArraySearch( $Array , $String , 1 , 0 , 0 , 0 , 1 , 0 )
    If NOT @Error Then
        Return $Array[$iFind][1]
    Else
        Return ''
    EndIf
EndFunc

post-2388-0-01481600-1391572890_thumb.pn

Edited by Nologic

Share this post


Link to post
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
Sign in to follow this  
Followers 0