# $language="Python" # $interface="1.0" # SetWordDelimiters.py # # Last Modified # 23 Feb, 2023 # - Added " and ' to the list of delimiters for the # "Email Addresses" characters set so that just # the component of an email address is selected, # exclusive of any surrounding ""s or ''s. # # 24 Aug, 2018 # - Correct strDelimSet3 and strDelimSet4 strings to # correctly escape the \ char via \\. # # 10 Dec, 2013 # - Initial revision # # DESCRIPTION: # Ever wanted double-click word selection to behave # differently depending on the current situation? # # For example, sometimes you might want double-click to # select everything bounded by spaces, while at other times # you may want to be able to select a word at the end of a # sentence without the trailing period being included in the # selection. # # SecureCRT's word delimiter functionality can be customized # to allow you to select text efficiently with the # double-click mouse action that you may need most of the # time. # # However, what about those times where you need slightly # different word selection behavior? Configuring a new word # delimiter character set might be too much overhead for # something you may only need for a short period of time. # # This example script shows one way of cycling through # different delimiter sets for double-click word selection. # Simply open SecureCRT's button bar and map a new button to # run this script. Every time you click on the button, # SecureCRT's word delimiters for that particular session # will rotate through 5 different word delimiter sets -- one # of which being the set defined in Global Options. # # If you're not yet familiar with SecureCRT's button bar, # visit our YouTube channel page and view the video: # https://www.youtube.com/watch?v=olyCcUWRimI # https://www.youtube.com/VanDykeSoftware MsgBox = crt.Dialog.MessageBox Prompt = crt.Dialog.Prompt # set up a list of desired delimiter sets as strings strDelimSet1 = " " strDelimSet2 = " <>()+=$%!#*\"'" strDelimSet3 = "` ~!@#$%^&*()+=:;>,\\[]{}|'" strDelimSet4 = "` ~!@#$%^&*()-+=:;.<>,\\/[]{}|'\"" strDelimSet5 = "" # Set up a map for naming the character sets defined cDelimNames = {} cDelimNames[strDelimSet1] = "Spaces" cDelimNames[strDelimSet2] = "Email Addresses" cDelimNames[strDelimSet3] = "Putty" cDelimNames[strDelimSet4] = "SecureCRT" cDelimNames[strDelimSet5] = "Unset (same as SecureCRT)" # Set up a cycling ring of delimeter sets (last one points back to first one) cDelimSets = {} cDelimSets[strDelimSet1] = strDelimSet2 cDelimSets[strDelimSet2] = strDelimSet3 cDelimSets[strDelimSet3] = strDelimSet4 cDelimSets[strDelimSet4] = strDelimSet5 cDelimSets[strDelimSet5] = strDelimSet1 def main(): crt.Session.SetStatusText("") crt.Sleep(100) strCurWordDelims = "" bUseWordDelims = crt.Session.Config.GetOption("Use Word Delimiter Chars") if not bUseWordDelims: crt.Session.Config.SetOption("Use Word Delimiter Chars", True) strCurWordDelims = crt.Session.Config.GetOption("Word Delimiter Chars") if strCurWordDelims in cDelimSets: strNewWordDelims = cDelimSets[strCurWordDelims] if strNewWordDelims == "": crt.Session.Config.SetOption("Use Word Delimiter Chars", False) else: strNewWordDelims = strDelimSet1 crt.Session.Config.SetOption("Word Delimiter Chars", strNewWordDelims) crt.Session.SetStatusText("Delim set: " + cDelimNames[strNewWordDelims]) crt.Sleep(100) main()