Scite additional functionality

This is where you can post about tools related specifically to the POL Server itself

Moderator: POL Developer

Post Reply
ThisIsMe
Distro Developer
Posts: 32
Joined: Sun Jul 17, 2016 1:29 am

Scite additional functionality

Post by ThisIsMe » Tue Jul 11, 2017 10:46 pm

I searched high and low for this and even higher and lower on how to get the damn thing to work (no joke on getting it to work, took me like 6 hours of fiddling about and searching through about 8 different websites/blogs before I figured out how to get it to be bound to a keyboard shortcut and another half hour to figure out how to get it to appear in the context menu). I've used it everyday since I found it a few days ago mainly converting cfg file stuff to hex while working on a tracking gump to create a new tracking.cfg file that is more up to date. It saved me a ton of time.

This will allow you to take a decimal number and convert it to hexadecimal and an hexadecimal and convert it to decimal all from a keyboard shortcut or right click context menu. (15 to 0xF or 0xF to 15 as an example)

Place functions below in SciteStartup.lua (Accessed via Options > Open Lua Startup Script)

Code: Select all

-- SciteConvertDecHex
-- Convert the selected text to decimal or hex
-- 2013.04.06 by lee.sheen at gmail dot com

function IsHexString (s)
  local header = string.sub(s, 1, 2)
  if "0x" == header or "0X" == header then
    return true
  else
    return false
  end
end

function ConvertDecHex ()
  local current_selected_text, current_selected_length = editor:GetSelText()
  local converted_number = tonumber(current_selected_text)
  if  not (converted_number == nil) then
    local converted_text = nil
    if IsHexString(current_selected_text) then
      converted_text = tostring(converted_number)
    else
      converted_text = string.format("0x%X", converted_number)
    end
    editor:ReplaceSel(converted_text)
  end
end
NEXT:
##########
# SCITEGlobal.properties
##########
Find: ext.lua.startup

Below it you will see:
ext.lua.auto.reload=1
#ext.lua.reset=0

where ext.lua.auto may or may not be commented out, I can not remember if it is by default,
I may have uncommented it in my experiments. But below these place the following bit:

Code: Select all

command.name.1.*=Convert Dec Hex
command.subsystem.1.*=3
command.1.*=ConvertDecHex
command.mode.1.*=savebefore:no
command.shortcut.1.*=Alt+Shift+C
AND THEN:
The following are additional keyboard shortcuts, many of which I copy and pasted from a blog (http://the-automator.com/scite-hotkeys/) I found and pruned out a few but not all the ones I don't use so, feel free to remove whichever ones you do not want.

Place in SCITEUser.properties (accessed via Options > Open User Options File)

Code: Select all

#******************User defined hot key commands*****************
user.shortcuts=\
Ctrl+Shift+V|IDM_PASTEANDDOWN|\
Ctrl+PageUp|IDM_PREVFILE|\
Ctrl+PageDown|IDM_NEXTFILE|\
Ctrl+Shift+Right|IDM_SWITCHPANE|\
Ctrl+Shift+Left|IDM_SWITCHPANE|\
Ctrl+Alt+c|IDM_COPYASRTF|\
Ctrl+F1|IDM_HELP_SCITE|\
Ctrl+PageUp|IDM_PREVFILE|\
Ctrl+PageDown|IDM_NEXTFILE|\
Ctrl+t|IDM_TOGGLEOUTPUT|\
Ctrl+Shift+t|IDM_SHOWCALLTIP|\
Ctrl+Shift+u|IDM_OPENUSERPROPERTIES|\
Ctrl+Escape|IDM_STOPEXECUTE|\
Alt+Shift+C|ConvertDecHex()|\
##################All comments need to be at end
#*****************User hotkeys end**************************************
AND FINALLY:
These are additional context menu short cuts I find useful, feel free to pull out whichever you do not want. These are also placed in the SCITEUser.properties file.

Code: Select all

#******************CONTEXT MENU*************************************.
# Add items to SciTE's context menu (right click menu)   #get others here: http://www.scintilla.org/CommandValues.html
user.context.menu=\
||\
Duplicate |IDM_DUPLICATE|\
||\
Save File |IDM_SAVE|\
Save File As |IDM_SAVEAS|\
Save a Copy |IDM_SAVEACOPY|\
||\
View White Space|IDM_VIEWSPACE|\
View End of Line|IDM_VIEWEOL|\
||\
Open File of Path Selected (no quotes) |IDM_OPENSELECTED|\
Copy as RTF |IDM_COPYASRTF|\
Copy Path of THIS File|IDM_COPYPATH|\
||\
Clear Output Pane |IDM_CLEAROUTPUT|\
Toggle Output Pane |IDM_TOGGLEOUTPUT|\
||\
Convert Decimal to Hexadecimal |1101|\
||\
Make Uppercase |IDM_UPRCASE|\
Make Lowercase |IDM_LWRCASE|\
||\
Compile Script |IDM_COMPILE|\
Note 1: The convert decimal to hex does a maximum number of 3755744320 (Would be nice if this were higher alas, i did not write it and am happy it does what I need it to and I can not foresee ever reaching that high of a number anyway)
Note 2: You may need to restart scite one all these things have been added, I did not but you never know.
Note 3: The shortcut for converting a number from hexadecimal to decimal and vise versa is set to Alt Shift C and accessible though the context menu (right click menu), the number must be highlighted in either case.
As always back up your stuff before dropping any of this stuff in.

Hope it helps.

Yukiko
Distro Developer
Posts: 2077
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Scite additional functionality

Post by Yukiko » Wed Jul 12, 2017 6:09 am

It helped me when you showed them to me.

Thanks for posting them.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest