Jump to content

[solved] SciTE-Lua: Selection problem


Recommended Posts

I've an unexpected behavior by selections  in SciTE.

The following script causes, the word under the cursor is selected. This can either apply to the Word character (by pressing Ctrl + Shift + E) or additionally with leading "$" for variables (by pressing Ctrl + E).

This works perfectly - as long as the right of the term is a space. If this is not so, then ranges are selected that do not correspond to the markers. Incidentally, it does not matter how I run the selection ( Selection Start / Stop; SetSel (); CharRightExtend () ), always the same behavior.

Any Ideas..

 Edit: Have found the failure - by default use SciTe "Ctrl+E" to match next brace. No i've changed the hotkey and it works like expected.  :shifty:

-------------------------------------------------------------------------
EditKey = EventClass:new(Common)
-------------------------------------------------------------------------

-------------------------------------------------------------------------
-- expand selection to full variable ($variable) or only the word characters (variable)
---------------- SetSelection( ) -----------------------------------------
function SetSelection(_part)
    local isWordChar = function(_char)
        if string.char(_char):find('[a-zA-Z0-9_]') then return true end
        return false
    end
    local iStart = editor.CurrentPos
    local iEnd = iStart
    while isWordChar(editor.CharAt[iStart-1]) do
        iStart = iStart - 1
    end
    if string.char(editor.CharAt[iStart-1]) == "$" and _part == false then iStart = iStart - 1 end
    while isWordChar(editor.CharAt[iEnd]) do
        iEnd = iEnd + 1
    end
    if iStart ~= iEnd then
        editor.SelectionStart = iStart
        editor.SelectionEnd   = iEnd
    end
end -->SetSelection
-------------------------------------------------------------------------

----------------- Event: OnKey -----------------------------------------
function EditKey:OnKey(_keycode, _shift, _ctrl, _alt)
    if _ctrl and     _shift and not _alt and _keycode == 69 then SetSelection(true) end   --- expand selection to full word with only Wordcharacters
    if _ctrl and not _shift and not _alt and _keycode == 69 then SetSelection(false) end  --- expand selection to full word with Wordcharacters and leading "$"
    return nil
end  --> EditKey
-------------------------------------------------------------------------
Edited by BugFix

Best Regards BugFix  

Link to comment
Share on other sites

  • Developers
 Edit: Have found the failure - by default use SciTe "Ctrl+E" to match next brace. No i've changed the hotkey and it works like expected.  :shifty:

 

I was just about to have a look and saw you also posted this question in the SciTE-Interest group.

Good to see it was solved.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I'm a little bit confused - it may be 1 or 2 hours after posting in Google groups, than i detected the solution by myself. Instantly i have deleted the post in Google groups. Where have you found this post now? I cant find them in the time line.

I've now seen, that Neil has also answered. Exists a copy of any posting there also if it is deleted?

Best Regards BugFix  

Link to comment
Share on other sites

Maybe it was still in the RSS feed?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Developers

I get an email with all-new-posts-of-the-day, for both SciTE and Scintilla, and saw it in there.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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