Skip to content

Instantly share code, notes, and snippets.

@mattst
mattst / TestQuickPanel.py
Last active November 12, 2016 14:04
ST plugin to try to reproduce r-stein quick panel bug
# { "keys": ["ctrl+whatever"], "command": "example" },
# { "keys": ["ctrl+whatever"], "command": "example_two" }
import sublime, sublime_plugin
# *********************
# WindowCommand Version
# *********************
@mattst
mattst / GetFileExtensionSyntax.py
Last active November 7, 2018 13:33
GetFileExtensionSyntax
# Proof of concept; retrieve the path of the syntax that a user has
# associated with any file extension in Sublime Text.
#
# 1) Create a temp file with the file extension of the desired syntax.
# 2) Open the temp file in ST with the API `open_file()` method; use a
# sublime.TRANSIENT buffer so that no tab is shown on the tab bar.
# 3) Retrieve the syntax ST has assigned to the view's settings.
# 4) Close the temp file's ST buffer.
# 5) Delete the temp file.
#
# Code to test the reliability of windll.kernel32.GetFileAttributesW()
# by running it on every file (that has read access) on the file system.
import os, os.path, sys
from ctypes import windll
HIDDEN_FILE_ATTRIBUTE = 2
GET_ATTRIBUTES_FAILED = -1

xev events for "xdotool click 3" launched with control + 8

FocusIn event, serial 37, synthetic NO, window 0x2c00001, mode NotifyGrab, detail NotifyPointer

KeymapNotify event, serial 37, synthetic NO, window 0x0, keys: 4294967188 0 2 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

@mattst
mattst / MouseWriteToDevice.c
Created March 6, 2018 15:25
Writes a left mouse button press or release event directly to the input device of the mouse.
/*
Writes a left mouse button press or release event
directly to the input device of the mouse.
Credit for barebones code: https://goo.gl/upXCqR
Currently takes one arg which must be either of:
BTN_LF_PRESS: write a left mouse button press event
BTN_LF_RELEASE: write a left mouse button release event
Written by: mattst@i-dig.info @ 2018-03-02
# The following methods are part of a project and are not stand-alone code. As
# such anyone wishing to re-use the code will have to modify it, note the use of
# the class variables `self.active_window` and `self.active_view` which would
# need to be changed to valid instances of the active `window` and `view`.
def set_syntax(self, path):
"""
Sets the syntax associated with the file extension of path.
There is no method to get the syntax of a file extension in the ST API.
@mattst
mattst / JumpToCharSeq.py
Created June 19, 2018 13:07
JumpToCharSeq.py
#
# Name: JumpToCharSeq (Jump To Character Sequence)
# Requirements: Plugin for Sublime Text v.3
# Written by: mattst@i-dig.info
#
# ST Command: jump_to_char_seq
#
# Optional Arg: direction
# -----------------------------------------------------------
@mattst
mattst / JumpToCharSeqFixed.py
Created June 22, 2018 15:22
JumpToCharSeqFixed.py
#
# Name: JumpToCharSeq (Jump To Character Sequence)
# Author: mattst@i-dig.info
# Requires: Sublime Text v3
#
# ST Command: jump_to_char_seq
# Optional Arg: direction --> "forwards" (default), "backwards"
# Optional Arg: case_sensitive --> boolean (default is false)
#
@mattst
mattst / ExpandSelectionByExpression.py
Created June 22, 2018 15:29
ExpandSelectionByExpression.py
#
# Name: Expand Selection By Expression
# Author: mattst@i-dig.info
# Requires: Sublime Text v3
#
# ST Command: expand_selection_by_expression
# Optional Arg: expression_type --> "regex" (default), "literal"
# Optional Arg: case_sensitive --> boolean (default is false)
#
@mattst
mattst / FocusMostRecentTabCloser.py
Last active September 25, 2018 20:52
Sublime Text 3 Plugin - Closes the focused view and focuses the next most recent view
#
# MIT License
#
# To use, assign keys to the "focus_most_recent_tab_closer" command, e.g.
# {"keys": ["ctrl+k", "ctrl+w"], "command": "focus_most_recent_tab_closer"},
#
import sublime
import sublime_plugin
import time