Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/01/2012 in all areas

  1. Is it ok to post SciTE LUA stuff here as well? I've updated my scripts for word highlighting in SciTE a la Notepad++. The new version allows to set a mode where any highlighted text is marked throughout the file, not just a whole word. In this mode, you can configure the minimum length of selected text to highlight. Here we go: SciTEUser.properties settings #global enable [0|1, def=1] highlight.sel.text=1 #whole word mode [0|1, def=1] highlight.whole.word=0 #min selected text length [integer, def=2] highlight.min.length=2LUA script (mine is loaded from its own file, so modify SciTEStartup.lua accordingly) MyTools = EventClass:new(Common) function MyTools:OnStartup() -- class property to hold active marker state so we only update when necessary self.bMarkersActive = false -- class property to indicate programatic marker clearing and avoid double UI update self.lastSelText = "" -- initialize missing props if props['highlight.sel.text'] ~= '0' and props['highlight.sel.text'] ~= '1' then props['highlight.sel.text'] = '1' end if props['highlight.whole.word'] ~= '0' and props['highlight.whole.word'] ~= '1' then props['highlight.whole.word'] = '1' end if props['highlight.min.length'] == '' then props['highlight.min.length'] = '2' end end function MyTools:OnUpdateUI() if props['highlight.sel.text'] == '1' then local selText = editor:GetSelText() -- check if selection has changed, update accordingly if selText == self.lastSelText then return false else self.lastSelText = selText end --print('update') local selStart = editor.SelectionStart local selEnd = editor.SelectionEnd -- check if selected text is an allowed word if selStart ~= selEnd and self:IsWord(selText) then -- check for word boundaries at ends of selection if props['highlight.whole.word'] == '0' or (not self:IsWord(string.char(editor.CharAt[selStart-1])) and not self:IsWord(string.char(editor.CharAt[selEnd]))) then self:markOccurrences(selText) else self:clearOccurrences() end else self:clearOccurrences() end end return false end function MyTools:IsWord(word) if props['highlight.whole.word'] == '1' then -- look for anything not allowed local find = string.find(word, '[^%a%d_$#@.]') if find == nil then return true else return false end else -- return true if selection length is >= highlight.min.length and no new lines local find = string.find(word, '[\r\n]') if find == nil and string.len(word) >= tonumber(props['highlight.min.length']) then return true else return false end end end function MyTools:clearOccurrences() if self.bMarkersActive then --print('clearing') scite.SendEditor(SCI_INDICATORCLEARRANGE, 0, editor.Length) self.bMarkersActive = false end end function MyTools:markOccurrences(selText) self:clearOccurrences() -- set flag markers are active self.bMarkersActive = true -- set indicator style local curIndic = 0 scite.SendEditor(SCI_SETINDICATORCURRENT, curIndic) scite.SendEditor(SCI_INDICSETALPHA, curIndic, 255) scite.SendEditor(SCI_INDICSETUNDER, curIndic, true) scite.SendEditor(SCI_INDICSETSTYLE, curIndic, INDIC_ROUNDBOX) scite.SendEditor(SCI_INDICSETFORE, curIndic, 0xFFF55D) -- set search flags --local flags = SCFIND_WHOLEWORD local flags = 0 -- find each occurrence of the word and set the indicator range local s,e = editor:findtext(selText, flags, 0) while s do scite.SendEditor(SCI_INDICATORFILLRANGE, s, e - s) s,e = editor:findtext(selText, flags, e+1) end end
    2 points
  2. Melba23

    new to combo/list boxes

    aerb, Or you could rid of the If statements altogether like this: #include <guiconstantsex.au3> $hGUI = GUICreate("My GUI combo") $hCombo = GUICtrlCreateCombo("", 10, 10) GUICtrlSetData(-1, "Andover|Berwick|Bockhampton|Bourne|Cranswick|Diss") $hButton = GUICtrlCreateButton("Read", 70, 70, 40, 40) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton Switch GUICtrlRead($hCombo) Case "Andover" MsgBox(0, "", "Test Andover") Case "Berwick" MsgBox(0, "", "Test Berwick") Case "Bockhampton" MsgBox(0, "", "Test Bockhampton") Case "Bourne" MsgBox(0, "", "Test Bourne") Case "Cranswick" MsgBox(0, "", "Test Cranswick") Case "Diss" MsgBox(0, "", "Test Diss") EndSwitch EndSwitch WEndPlease ask if you have any questions. M23 P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. Edit: Just noticed this is my 10,000th post.
    1 point
  3. If you are ready with your fileread commands, then you can concatenate your variables by using : $a = $a & $b or in short $a &= $b
    1 point
  4. In an Active Directory environment it would be absurd to "push" a logon script using psexec, instead you use Group Policy.
    1 point
×
×
  • Create New...