Jump to content

howto add entry to %userprofile%\abbrev.properties?


rudi
 Share

Recommended Posts

Hi.

I'd like to add this entry to the "abbrev.properties" file in my user profile's Dir (also tried SciTEUser.properties):

#; -- Macro's --
ConsoleWrite(@ScriptLineNumber & " |" & @LF)\n

Even after saving, exiting SciTE, reopening the editor, it still has no effect. Also very simple entries like

myword=ThisIsJustOneWord

don't work...

When I change an existing entry it's effective immediately:

; old entry: cr1=& @CRLF
cr1=& @CRLF  & _\n|

Propably there is another file to be edited as well? I don't find howto, it in either, SciTE or Autoit help files :D

Who pls can point me to the right documentation?

Thanks, Rudi.

edit: The SciTE for Autoi3 help file tells it should work?

The Abbreviations file is in the Options menu of SciTE.
Have a look at the syntax required to use them.
You can add some of you own into the list.
Let's use SciTE, closer to it's full usefulness;)
Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

In the German Forum, BugFix made a Script to do that. (http://www.autoit.de/index.php?page=Thread&threadID=5229), ATM it's down :D

This is the Script:

; Abbrev ManageMent (Abbrevverwaltung.au3)
; Script by BugFix
#include <GUIConstants.au3>
#include <File.au3>
#include <GUIListView.au3>
#Include <GuiEdit.au3>
Opt("GUIOnEventMode", 1)

Global $ScitePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SciTE.exe","")
Global $KeyWordPath = StringReplace($ScitePath, "SciTE.exe", "properties\au3.keywords.abbreviations.properties")
Global $Abbr_Path = @UserProfileDir & '\abbrev.properties'
Global $Start_STR = '#; -- Gui Variables --', $start = False, $edit = False
Global $Last_STR = '#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#'
Global $txt, $aTitel[2] = ['Code für neue Abkürzung', 'Code bearbeiten']
Global $aLabel[2] = [ _
'Bitte den Code für die Abkürzung einfügen. Einrückungen bitte mit Tabulator (Im Editfeld durch STRG+TAB).' & @LF & _
        'Für die gewünschte Cursorposition:  |  verwenden. Der Code wird beim Schließen des Fensters übernommen.', _
'Hier den Code bearbeiten. Einrückungen bitte mit Tabulator (Im Editfeld durch STRG+TAB).' & @LF & _
        'Für die gewünschte Cursorposition:  |  verwenden. Der Code wird beim Schließen des Fensters übernommen.']
Global $aAbbrev, $k = 0
_FileReadToArray($Abbr_Path, $aAbbrev)

$Form1 = GUICreate("Abkürzungen verwalten  [" & $Abbr_Path & ']', 800, 600, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$iSearch = GUICtrlCreateInput('', 15, 10, 90, 20)
$bSearch = GUICtrlCreateButton('Suchen', 125, 10, 150, 20, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, '_Search')
$bCreate = GUICtrlCreateButton('Hinzufügen', 295, 10, 150, 20)
GUICtrlSetOnEvent(-1, '_Create')
$bEdit = GUICtrlCreateButton('Bearbeiten', 465, 10, 150, 20)
GUICtrlSetOnEvent(-1, '_Edit')
$bDelete = GUICtrlCreateButton('Löschen', 635, 10, 150, 20)
GUICtrlSetOnEvent(-1, '_Delete')
$ListView1 = GUICtrlCreateListView("Abkürzung|Code", 15, 40, 770, 545, BitOR($LVS_SHOWSELALWAYS,$LVS_SINGLESEL,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetOnEvent(-1, "ListView1Click")
GUICtrlSetBkColor(-1, 0xE0FFFF)
GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_ONECLICKACTIVATE)
_GUICtrlListView_SetColumnWidth(-1, 0, 90)
_GUICtrlListView_SetColumnWidth(-1, 1, $LVSCW_AUTOSIZE_USEHEADER)

_LV_Fill()

$Form2 = GUICreate('Code zur Abkürzung', 700, 400, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
$Edit1 = GUICtrlCreateEdit('', 10, 10, 680, 380, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)); BitOR($WS_HSCROLL,$WS_VSCROLL,$ES_READONLY))
GUICtrlSetBkColor(-1, 0x98FB98)

$Form3 = GUICreate('Code für neue Abkürzung', 700, 400, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form3Close")
$Label1 = GUICtrlCreateLabel('Bitte den Code für die Abkürzung einfügen. Einrückungen bitte mit Tabulator (Im Editfeld durch STRG+TAB).' & @LF & _
        'Für die gewünschte Cursorposition:  |  verwenden. Der Code wird beim Schließen des Fensters übernommen.' _
        , 10, 5, 680, 30, $SS_SUNKEN+$SS_CENTER)
GUICtrlSetBkColor(-1, 0x98FB98)
$Edit2 = GUICtrlCreateEdit('', 10, 40, 680, 350, BitOR($WS_HSCROLL,$WS_VSCROLL,$ES_MULTILINE,$ES_WANTRETURN))
GUICtrlSetBkColor(-1, 0x98FB98)

GUISetState(@SW_SHOW, $Form1)
GUIRegisterMsg($WM_NOTIFY, "MY_WM_COMMAND")

While 1
    Sleep(100)
WEnd

Func Form1Close()
    Exit
EndFunc
Func Form2Close()
    GUISetState(@SW_HIDE, $Form2)
    GUICtrlSetData($Edit1, '')
EndFunc
Func Form3Close()
    GUISetState(@SW_HIDE, $Form3)
    If $edit Then
        _WriteEditedAbbrev()
    Else
        _WriteNewAbbrev()
    EndIf
EndFunc

Func _Search()
    $txt = GUICtrlRead($iSearch)
    If $txt = '' Then Return
    Local $indx = _LV_FindInSubItem($ListView1, $txt, 0)
    If $indx = -1 Then
        MsgBox(0, 'Suche Abbrev', 'Das Abbrev: "' & $txt & '" ist noch nicht erstellt.')
    Else
        _GUICtrlListView_EnsureVisible($ListView1, $indx)
        _GUICtrlListView_SetItemDropHilited($ListView1, $indx)
    EndIf
EndFunc

Func _Create()
    $txt = GUICtrlRead($iSearch)
    If $txt = '' Then Return MsgBox(16, 'Fehler', 'Keine Abkürzung eingetragen.')
    Local $indx = _LV_FindInSubItem($ListView1, $txt, 0)
    If $indx > -1 Then Return MsgBox(16, 'Fehler', 'Die Abkürzung existiert bereits.')
    $edit = False
    WinSetTitle($Form3, '', $aTitel[0])
    GUICtrlSetData($Label1, $aLabel[0])
    GUISetState(@SW_SHOW, $Form3)
EndFunc

Func _Edit()
    $txt = GUICtrlRead($iSearch)
    If $txt = '' Then Return MsgBox(16, 'Fehler', 'Keine Abkürzung ausgewählt.')
    $edit = True
    WinSetTitle($Form3, '', $aTitel[1])
    GUICtrlSetData($Label1, $aLabel[1])
    GUICtrlSetData($Edit2, _Abbrev2Code(_GUICtrlListView_GetItemText($ListView1, _LV_FindInSubItem($ListView1, $txt, 0), 1)))
    GUISetState(@SW_SHOW, $Form3)
EndFunc

Func _LV_FindInSubItem($hWnd, $2Find, $SubIndex)
    Local $out = -1
    For $i = 0 To _GUICtrlListView_GetItemCount($hWnd) -1
        If _GUICtrlListView_GetItemText($hWnd, $i, $SubIndex) = $2Find Then $out = $i
    Next
    Return $out
EndFunc

Func ListView1Click()
    GUICtrlSetData($iSearch, _GUICtrlListView_GetItemText($ListView1, _GUICtrlListView_GetHotItem($ListView1), 0))
    GUICtrlSetData($Edit1, _Abbrev2Code(_GUICtrlListView_GetItemText($ListView1, _GUICtrlListView_GetHotItem($ListView1), 1)))
    GUISetState(@SW_SHOW, $Form2)
EndFunc

Func _LV_Fill()
    For $i = 1 To UBound($aAbbrev) -1
        If $aAbbrev[$i] = $Start_STR Then $start = True
        If (Not $start) Or (StringLeft($aAbbrev[$i], 1) = '#') Or ($aAbbrev[$i] = '') Then ContinueLoop
        $var = _SplitOnce($aAbbrev[$i], '=')
        GUICtrlCreateListViewItem('|', $ListView1)
        _GUICtrlListView_SetItemText($ListView1, $k, $var[0], 0)
        _GUICtrlListView_SetItemText($ListView1, $k, $var[1], 1)
        $k += 1
    Next
EndFunc

Func _SplitOnce($STRING, $DELIM)
    Local $Out[2]
    Local $len = StringLen($STRING)
    Local $pos = StringInStr($STRING, $DELIM, 1, 1)
    $Out[0] = StringLeft($STRING, $pos-1)
    $Out[1] = StringRight($STRING, $len-$pos)
    Return $Out
EndFunc

Func _Abbrev2Code($ABBREV)
    Local $out = ''
    $var = StringSplit($ABBREV, '\n', 1)
    For $i = 1 To UBound($var) -1
        If StringInStr($var[$i], '\t', 1) Then $var[$i] = StringReplace($var[$i], '\t', @TAB)
        If $i = UBound($var) -1 Then
            $out &= $var[$i]
        Else
            $out &= $var[$i] & @CRLF
        EndIf
    Next
    Return $out
EndFunc

Func _Code2Abbrev()
    Local $out = '', $count = _GUICtrlEdit_GetLineCount($Edit2), $line
    If @error Then Return SetError(1)
    For $i = 0 To $count -1
        $line = _GUICtrlEdit_GetLine($Edit2, $i)
        If StringInStr($line, @TAB, 1) Then $line = StringReplace($line, @TAB, '\t')
        If $i = $count -1 Then
            $out &= $line
        Else
            $out &= $line & '\n'
        EndIf
    Next
    Return $out
EndFunc

Func _WriteNewAbbrev()
    If GUICtrlRead($Edit2) = '' Then Return
    Local $abbr = _Code2Abbrev()
    ReDim $aAbbrev[UBound($aAbbrev)+1]
    $aAbbrev[UBound($aAbbrev)-1] = $txt & '=' & $abbr
    For $i = UBound($aAbbrev) -1 To 1 Step -1
        If $aAbbrev[$i] = $Last_STR Then ExitLoop
    Next
    _ArraySwap($aAbbrev[UBound($aAbbrev)-1], $aAbbrev[$i])
    FileMove($Abbr_Path, $Abbr_Path & '.BAK', 1)
    _FileWriteFromArray($Abbr_Path, $aAbbrev, 1)
    _KeyWordSet($txt)
    _FileReadToArray($Abbr_Path, $aAbbrev)
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
    GUICtrlSetData($Edit2, '')
    $start = False
    $k = 0
    _LV_Fill()
    _GUICtrlListView_EnsureVisible($ListView1, $k-1)
    _GUICtrlListView_SetItemDropHilited($ListView1, $k-1)
EndFunc

Func _WriteEditedAbbrev()
    If GUICtrlRead($Edit2) = '' Then Return
    Local $abbr = _Code2Abbrev()
    Local $line = _GetLine()-1
    Local $idx = _LV_FindInSubItem($ListView1, $txt, 0)
    $aAbbrev[$line] = $txt & '=' & $abbr
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
    GUICtrlSetData($Edit2, '')
    $start = False
    $k = 0
    _LV_Fill()
    _FileWriteToLine($Abbr_Path, $line, $txt & '=' & $abbr, 1)
    _GUICtrlListView_EnsureVisible($ListView1, $idx)
    _GUICtrlListView_SetItemDropHilited($ListView1, $idx)
EndFunc

Func _Delete()
    $txt = GUICtrlRead($iSearch)
    If MsgBox(262180, 'ACHTUNG', 'Soll die Abkürzung' & @LF & '>> ' & $txt & ' <<' & @LF & 'wirklich gelöscht werden?') = 7 Then Return
    Local $idx = _GetLine()-1
    $aAbbrev[$idx] = ''
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
    GUICtrlSetData($iSearch, '')
    $start = False
    $k = 0
    _LV_Fill()
    _FileWriteToLine($Abbr_Path, $idx, '', 1)
    Local $keys = FileRead($KeyWordPath)
    $keys = StringReplace($keys, $txt & ' ', '', 1, 1)
    Local $fh = FileOpen($KeyWordPath, 2)
    FileWrite($fh, $keys)
    FileClose($fh)
EndFunc

Func _GetLine()
    Local $var
    For $i = 1 To UBound($aAbbrev) -1
        $var = _SplitOnce($aAbbrev[$i], '=')
        If $var[0] = $txt Then Return $i+1
    Next
EndFunc

Func _KeyWordSet($KEYWORD)
    Local $txtZeile, $len
    $zeile = _FileCountLines($KeyWordPath)
    $txtZeile = FileReadLine($KeyWordPath, $zeile)
    $len = StringLen($txtZeile) +4
    If $len + StringLen($KEYWORD) > 100 Then
        _FileWriteToLine($KeyWordPath, $zeile, $txtZeile & "\" & @CRLF, 1)
        _FileWriteToLine($KeyWordPath, $zeile+1, @TAB & $KEYWORD & " ", 1)
    Else
        _FileWriteToLine($KeyWordPath, $zeile, $txtZeile & $KEYWORD & " ", 1)
    EndIf
EndFunc

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $tagNMHDR, $event
    Switch $wParam
        Case $ListView1
            $tagNMHDR = DllStructCreate("int;int;int", $lParam)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $NM_CLICK
                    ListView1Click()
            EndSwitch
    EndSwitch
    $tagNMHDR = 0
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Thanks, it's working perfectly :D

Und auch noch gleich in der richtigen Sprache :D

(transl.: And even the right language as well)

I didn't readup this nice code so far -- shouldn't it work with plain text add as well as by the help file??

Danke, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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...