Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 618657cd8e66618f2859f7231c67d92db57b107d @msiniscalchi msiniscalchi committed Mar 22, 2011
@@ -0,0 +1,67 @@
+import sublime, sublime_plugin
+from ctypes import *
+
+# Send DDE Execute command to running program
+
+class send_ddeCommand(sublime_plugin.TextCommand):
+ def run(self, edit, service = "", topic = "", command = ""):
+
+ print "Got request for DDE!"
+
+ # define win32 api functions
+ DdeInitialize = windll.user32.DdeInitializeW
+ DdeUninitialize = windll.user32.DdeUninitialize
+ DdeConnect = windll.user32.DdeConnect
+ DdeDisconnect = windll.user32.DdeDisconnect
+ DdeClientTransaction = windll.user32.DdeClientTransaction
+ DdeCreateStringHandle = windll.user32.DdeCreateStringHandleW
+ DdeFreeStringHandle = windll.user32.DdeFreeStringHandle
+ DdeFreeDataHandle = windll.user32.DdeFreeDataHandle
+
+ # Dde callback definition
+ DDECALLBACK = WINFUNCTYPE(c_void_p, c_uint, c_uint, c_void_p, c_void_p, c_void_p, c_void_p,
+ c_ulong, c_ulong)
+
+ def py_mycallback(uType, uFmt, hconv, hsz1, hsz2, hdata, dwData1, dwData2):
+ return 0
+
+ mycallback = DDECALLBACK(py_mycallback)
+
+ # Instance ID (filled out by DdeInitialize)
+ idInst = c_uint(0)
+ # Conversation handle
+ hConv = 0
+ # server and topic names, as LPTSTR = wchar *
+ service = c_wchar_p(service)
+ topic = c_wchar_p(topic)
+ pData = c_char_p(command)
+ cbData = len(command)
+
+ # initialize
+ ret = DdeInitialize(byref(idInst), pointer(mycallback), 0, 0)
+ # for the next two calls, the last param is the codepage:
+ # 1004 = CP_Winansi, 1200 = CP_WINUNICODE
+ hszService = DdeCreateStringHandle(idInst, service, 1200)
+ hszTopic = DdeCreateStringHandle(idInst, topic, 1200)
+ hConv = DdeConnect(idInst, hszService, hszTopic, 0)
+
+ if hConv: # zero means we could not connect for some reason
+ #print "start!"
+ XTYP_EXECUTE = int("4050",16) # transaction type; note -1 for timeout_async
+ hDdeData = DdeClientTransaction(pData, cbData, hConv, 0, 0, XTYP_EXECUTE, 10000, 0)
+ print "DDE Execute returned: ", hex(windll.user32.DdeGetLastError(idInst))
+ DdeFreeDataHandle(hDdeData)
+
+ #print ret, idInst, hszService, hszTopic, hConv
+
+ # test of string handles
+ #buf = create_string_buffer(200)
+ #print windll.user32.DdeQueryStringW(idInst, hszService, buf, 100, 1200)
+ #print repr(buf.raw)
+ # OK, this works!
+
+ DdeFreeStringHandle(idInst, hszTopic)
+ DdeFreeStringHandle(idInst, hszService)
+ DdeDisconnect(hConv)
+ DdeUninitialize(idInst)
+
Binary file not shown.
@@ -0,0 +1,63 @@
+/*
+LaTeX Package keymap for OSX
+*/
+[
+ { "keys": ["ctrl+alt+t"], "command": "texify" },
+ { "keys": ["ctrl+alt+s"], "command": "tex_sections" },
+ /* why not use TextMate's keybindings?
+ we only clobber next-tab and previous-tab, whihc are also bound
+ to arrow keys */
+ { "keys": ["super+shift+right_bracket"], "command": "latexcmd"},
+ { "keys": ["super+shift+left_bracket"], "command": "latexenv"},
+ { "keys": ["super+shift+period"], "command": "latex_env_closer"},
+ /* can't use forward slash or period; also, why not CMD? */
+ { "keys": ["super+alt+forward_slash"], "command": "tex_macro"},
+ /* alternatives: the second is reminiscent of super+B for build */
+ { "keys": ["ctrl+alt+v"], "command": "view_pdf"},
+ { "keys": ["ctrl+alt+r"], "command": "tex_ref"},
+ { "keys": ["super+shift+j"], "command": "jump_to_pdf"},
+ { "keys": ["super+shift+b"], "command": "view_pdf"},
+
+ // Auto-pair ``$''
+ // Lifted from default file
+ // insert matching $
+ // note the "key": "selector" line!
+ { "keys": ["$"], "command": "insert_snippet", "args": {"contents": "\\$$0\\$"},
+ "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
+ /*{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|])", "match_all": true },*/
+ { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true },
+ { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }
+ ]
+ },
+ // wrap in $
+ { "keys": ["$"], "command": "insert_snippet", "args": {"contents": "\\$${0:$SELECTION}\\$"}, "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
+ ]
+ },
+ // move over closing $
+ { "keys": ["$"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
+ { "key": "following_text", "operator": "regex_contains", "operand": "^\\$", "match_all": true }
+ ]
+ },
+ // delete $ pair
+ { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Left Right.sublime-macro"}, "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
+ { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$$", "match_all": true },
+ { "key": "following_text", "operator": "regex_contains", "operand": "^\\$", "match_all": true }
+ ]
+ }
+]
@@ -0,0 +1,67 @@
+/*
+LaTeX Package keymap for OSX
+*/
+[
+ // subsumed by build configuration
+ // { "keys": ["ctrl+alt+t"], "command": "texify" },
+ // not yet active
+ // { "keys": ["ctrl+alt+s"], "command": "tex_sections" },
+ /* why not use TextMate's keybindings?
+ we only clobber next-tab and previous-tab, whihc are also bound
+ to arrow keys */
+ { "keys": ["alt+shift+right_bracket"], "command": "latexcmd"},
+ { "keys": ["alt+shift+left_bracket"], "command": "latexenv"},
+ { "keys": ["alt+shift+period"], "command": "latex_env_closer"},
+ /* can't use forward slash or period; also, why not CMD? */
+ // subsumed by tab completion
+ // { "keys": ["super+alt+forward_slash"], "command": "tex_macro"},
+ /* alternatives: the second is reminiscent of super+B for build */
+ { "keys": ["ctrl+alt+v"], "command": "view_pdf"},
+ // subsumed by ref<TAB> and completion API
+ // { "keys": ["ctrl+alt+r"], "command": "tex_ref"},
+ { "keys": ["alt+shift+j"], "command": "jump_to_pdf"},
+ { "keys": ["super+shift+b"], "command": "view_pdf"},
+
+ // Auto-pair ``$''
+ // Lifted from default file
+ // insert matching $
+ // note the "key": "selector" line!
+ { "keys": ["$"], "command": "insert_snippet", "args": {"contents": "\\$$0\\$"},
+ "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
+ /*{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|])", "match_all": true },*/
+ { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true },
+ { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }
+ ]
+ },
+ // wrap in $
+ { "keys": ["$"], "command": "insert_snippet", "args": {"contents": "\\$${0:$SELECTION}\\$"}, "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
+ ]
+ },
+ // move over closing $
+ { "keys": ["$"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
+ { "key": "following_text", "operator": "regex_contains", "operand": "^\\$", "match_all": true }
+ ]
+ },
+ // delete $ pair
+ { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Left Right.sublime-macro"}, "context":
+ [
+ {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
+ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
+ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
+ { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$$", "match_all": true },
+ { "key": "following_text", "operator": "regex_contains", "operand": "^\\$", "match_all": true }
+ ]
+ }
+]
@@ -0,0 +1,117 @@
+{
+ "scope": "string.other.math.tex, string.other.math.latex, string.other.math.block.environment.latex",
+
+ "completions":
+ [
+ { "trigger": "a", "contents": "\\alpha" },
+ { "trigger": "b", "contents": "\\beta" },
+ { "trigger": "g", "contents": "\\gamma" },
+ { "trigger": "d", "contents": "\\delta" },
+ { "trigger": "e", "contents": "\\epsilon" },
+ { "trigger": "epsilon", "contents": "varepsilon" }, /* toggle the two! */
+ { "trigger": "varepsilon", "contents": "epsilon" },
+ { "trigger": "z", "contents": "\\zeta"},
+ { "trigger": "h", "contents": "\\eta" },
+ { "trigger": "q", "contents": "\\theta" },
+ { "trigger": "theta", "contents": "vartheta" },
+ { "trigger": "vartheta", "contents": "theta" },
+ { "trigger": "i", "contents": "\\iota" },
+ { "trigger": "k", "contents": "\\kappa" },
+ { "trigger": "l", "contents": "\\lambda" },
+ { "trigger": "m", "contents": "\\mu" },
+ { "trigger": "n", "contents": "\\nu" },
+ { "trigger": "x", "contents": "\\xi" },
+ { "trigger": "p", "contents": "\\pi" },
+ { "trigger": "r", "contents": "\\rho" },
+ { "trigger": "s", "contents": "\\sigma" },
+ { "trigger": "t", "contents": "\\tau" },
+ { "trigger": "u", "contents": "\\upsilon" },
+ { "trigger": "f", "contents": "\\phi" },
+ { "trigger": "phi", "contents": "varphi" },
+ { "trigger": "varphi", "contents": "phi" },
+ { "trigger": "c", "contents": "\\chi" },
+ { "trigger": "y", "contents": "\\psi" },
+ { "trigger": "w", "contents": "\\omega" },
+ { "trigger": "v", "contents": "\\digamma"},
+ { "trigger": "G", "contents": "\\Gamma" },
+ { "trigger": "D", "contents": "\\Delta" },
+ { "trigger": "Q", "contents": "\\Theta" },
+ { "trigger": "L", "contents": "\\Lambda" },
+ { "trigger": "X", "contents": "\\Xi" },
+ { "trigger": "P", "contents": "\\Pi" },
+ { "trigger": "S", "contents": "\\Sigma" },
+ { "trigger": "F", "contents": "\\Phi" },
+ { "trigger": "Y", "contents": "\\Psi" },
+ { "trigger": "W", "contents": "\\Omega" },
+
+ { "trigger": "0", "contents": "\\emptyset" },
+ { "trigger": "V", "contents": "\\forall" },
+ { "trigger": "E", "contents": "\\exists" },
+ { "trigger": "sm", "contents": "\\setminus" },
+ { "trigger": "ld", "contents": "\\ldots" },
+ { "trigger": "cd", "contents": "\\cdot" },
+ { "trigger": "cdot", "contents": "cdots" },
+ { "trigger": "cdots", "contents": "cdot"},
+
+ { "trigger": "la", "contents": "\\langle"},
+ { "trigger": "ra", "contents": "\\rangle"},
+ { "trigger": "cu", "contents": "\\cup"},
+ { "trigger": "ca", "contents": "\\cap"},
+ { "trigger": "bcu", "contents": "\\bigcup"},
+ { "trigger": "bca", "contents": "\\bigcap"},
+
+ { "trigger": "in", "contents": "\\int"},
+ { "trigger": "int", "contents": "infty"},
+ { "trigger": "infty", "contents": "int"},
+
+ { "trigger": "su", "contents": "\\sum"},
+ { "trigger": "sum", "contents": "sup"},
+ { "trigger": "sup", "contents": "succ"},
+ { "trigger": "succ", "contents": "succeq"},
+ { "trigger": "succeq", "contents": "succcurlyeq"},
+ { "trigger": "succcurlyeq", "contents": "sum"},
+
+ { "trigger": "qd", "contents": "\\quad"},
+ { "trigger": "qqd", "contents": "\\qquad"},
+
+ { "trigger": "pr", "contents": "\\prod"},
+ { "trigger": "prod", "contents": "prec"},
+ { "trigger": "prec", "contents": "preceq"},
+ { "trigger": "preceq", "contents": "preccurlyeq"},
+ { "trigger": "preccurlyeq", "contents": "prod"},
+
+ { "trigger": "lar", "contents": "\\leftarrow"},
+ { "trigger": "leftarrow", "contents": "longleftarrow"},
+ { "trigger": "longleftarrow", "contents": "leftarrow"},
+ { "trigger": "Lar", "contents": "\\Leftarrow"},
+ { "trigger": "Leftarrow", "contents": "Longleftarrow"},
+ { "trigger": "Longleftarrow", "contents": "Leftarrow"},
+ { "trigger": "rar", "contents": "\\rightarrow"},
+ { "trigger": "rightarrow", "contents": "longrightarrow"},
+ { "trigger": "longrightarrow", "contents": "rightarrow"},
+ { "trigger": "Rar", "contents": "\\Rightarrow"},
+ { "trigger": "Rightarrow", "contents": "Longrightarrow"},
+ { "trigger": "Longrightarrow", "contents": "Rightarrow"},
+ { "trigger": "lr", "contents": "\\leftrightarrow"},
+ { "trigger": "Lr", "contents": "\\Leftrightarrow"},
+ { "trigger": "iff", "contents": "\\Leftrightarrow"},
+ { "trigger": "Leftrightarrow", "contents": "Longleftrightarrow"},
+ { "trigger": "Longleftrightarrow", "contents": "rightarrow"},
+ { "trigger": "up", "contents": "\\uparrow"},
+ { "trigger": "do", "contents": "\\downarrow"},
+
+ { "trigger": "it", "contents": "\\mathit{$1}$0"},
+ { "trigger": "bf", "contents": "\\mathbf{$1}$0"},
+ { "trigger": "bb", "contents": "\\mathbb{$1}$0"},
+ { "trigger": "rm", "contents": "\\mathrm{$1}$0"},
+ { "trigger": "sf", "contents": "\\mathsf{$1}$0"},
+ { "trigger": "cal", "contents": "\\mathcal"},
+ { "trigger": "mathcal", "contents": "mathcal{$1}$0"},
+
+ { "trigger": "lp", "contents": "\\left( $1 \\right) $0"},
+ { "trigger": "lb", "contents": "\\left[ $1 \\right] $0"},
+ { "trigger": "lbr", "contents": "\\left\\\\{ $0 \\right\\\\}"},
+ { "trigger": "fr", "contents": "\\frac"}
+
+ ]
+}
@@ -0,0 +1,27 @@
+/* Let's not preview for now. This should be OK on Win/MikTeX, too (?) */
+/* Make sure latexmk is on the $PATH, AND add it to .MacOSX/environment.plist */
+
+{
+ "cmd": ["latexmk",
+ "-e", "\\$pdflatex = 'pdflatex %O -file-line-error --max-print-line=200 -synctex=1 %S'",
+ "-e", "\\$pdf_previewer = qq{if [ -n \"`ps axww | grep Skim | grep -v grep`\" ] ; then osascript -e 'tell app \"Skim\" to revert front document' ; else open -a Skim %O %S ; fi}",
+ //"-e", "\\$pdf_previewer = qq{/Applications/Skim.app/Contents/SharedSupport/displayline -g -r 0 %S}",
+ "-pv", "-pdf", "$file"],
+ "working_dir": "$file_path", /* crucial or latexmk will spew stuff in /!!! */
+ "file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
+ "selector": "text.tex.latex",
+
+ // Windows-specific command
+ // ASSUMES sumatrapdf is default viewer
+ // Only problem is that it comes to the foreground
+ "windows":
+ {
+ "cmd": ["texify", "-b", "-p",
+ "--tex-option=\"--synctex=1\"",
+ "--tex-option=\"--max-print-line=200\"",
+ "--tex-option=\"-file-line-error\"",
+ "--run-viewer",
+ "--viewer-option=\"-reuse-instance\"",
+ "$file"]
+ }
+}
@@ -0,0 +1,23 @@
+{
+ "scope": "text.tex.latex",
+
+ "completions":
+ [
+ { "trigger": "it", "contents": "\\textit{$1}$0"},
+ { "trigger": "bf", "contents": "\\textbf{$1}$0"},
+ { "trigger": "em", "contents": "\\emph{$1}$0"},
+ { "trigger": "tt", "contents": "\\texttt{$1}$0"},
+ { "trigger": "un", "contents": "\\underline{$1}$0"},
+
+ { "trigger": "bs", "contents": "\\bigskip"},
+ { "trigger": "ms", "contents": "\\medskip"},
+ { "trigger": "ss", "contents": "\\smallskip"},
+
+ { "trigger": "use", "contents": "\\usepackage"},
+
+ { "trigger": "bit", "contents": "\\begin{itemize}\n\t\\item $1 \n\\end{itemize}\n"},
+ { "trigger": "ben", "contents": "\\begin{enumerate}\n\t\\item $1 \n\\end{enumerate}\n"},
+ { "trigger": "i", "contents": "\\item "}
+
+ ]
+}
Oops, something went wrong.

0 comments on commit 618657c

Please sign in to comment.