Skip to content

Commit

Permalink
improve indent (tabs spaces)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownuser88 committed Mar 15, 2018
1 parent 8cc4d45 commit 2a53f3c
Show file tree
Hide file tree
Showing 9 changed files with 777 additions and 777 deletions.
22 changes: 11 additions & 11 deletions .sublime/Context.sublime-menu
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[
{ "caption": "-" },
{
"caption": "Console Wrap",
"children":
[
{ "command": "console_action", "args": {"action": "comment"}, "caption": "Comment All logs" },
{ "command": "console_action", "args": {"action": "remove_commented"}, "caption": "Remove Commented logs" },
{ "command": "console_action", "args": {"action": "remove"}, "caption": "Remove All logs" },
{ "command": "console_action", "args": {"action": "show_quick_nav"}, "caption": "Show all logs"}
{ "caption": "-" },
{
"caption": "Console Wrap",
"children":
[
{ "command": "console_action", "args": {"action": "comment"}, "caption": "Comment All logs" },
{ "command": "console_action", "args": {"action": "remove_commented"}, "caption": "Remove Commented logs" },
{ "command": "console_action", "args": {"action": "remove"}, "caption": "Remove All logs" },
{ "command": "console_action", "args": {"action": "show_quick_nav"}, "caption": "Show all logs"}

]
}
]
}
]
112 changes: 56 additions & 56 deletions .sublime/Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
[{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "Console Wrap",
"children":
[
{
"caption": "Settings",
"command": "console_wrap_edit_settings",
"args": {
"base_file": "${packages}/Console Wrap/.sublime/consolewrap.sublime-settings",
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "Console Wrap",
"children":
[
{
"caption": "Settings",
"command": "console_wrap_edit_settings",
"args": {
"base_file": "${packages}/Console Wrap/.sublime/consolewrap.sublime-settings",
"default": "// Settings in here override those in \"${packages}/User/consolewrap.sublime-settings\",\n\n{\n\t$0\n}\n"
}
},
{
"caption": "Settings - Default",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/Console Wrap/.sublime/consolewrap.sublime-settings"}
},
{
"caption": "Settings - User",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/User/consolewrap.sublime-settings"}
},
{ "caption": "-" },
{
"caption": "Key Bindings",
"command": "console_wrap_edit_settings",
"args": {
"base_file": "${packages}/Console Wrap/.sublime/Default (${platform}).sublime-keymap",
"default": "// Console Wrap Key Bindings - User\n{\n\t$0\n}\n"
}
},
{
"caption": "Key Bindings - Default",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/Console Wrap/.sublime/Default (${platform}).sublime-keymap"}
},
{
"caption": "Key Bindings - User",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/User/Default (${platform}).sublime-keymap"}
}
]
}
]
}
]
}
},
{
"caption": "Settings - Default",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/Console Wrap/.sublime/consolewrap.sublime-settings"}
},
{
"caption": "Settings - User",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/User/consolewrap.sublime-settings"}
},
{ "caption": "-" },
{
"caption": "Key Bindings",
"command": "console_wrap_edit_settings",
"args": {
"base_file": "${packages}/Console Wrap/.sublime/Default (${platform}).sublime-keymap",
"default": "// Console Wrap Key Bindings - User\n{\n\t$0\n}\n"
}
},
{
"caption": "Key Bindings - Default",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/Console Wrap/.sublime/Default (${platform}).sublime-keymap"}
},
{
"caption": "Key Bindings - User",
"command": "console_wrap_open_file",
"args": {"file": "${packages}/User/Default (${platform}).sublime-keymap"}
}
]
}
]
}
]
}]
52 changes: 26 additions & 26 deletions .sublime/consolewrap.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"js": {
"consoleStr" : "{title}, {variable}", // "{title}, tmpVal = {variable}" to assigne value to temporary parameter output: console.log('title', tmpVal = variable);
"consoleFunc" : ["console", "log"], // You can change default log statement for example ["logger", "info"] output: logger.info('title', variable);
"single_quotes": false, // If true output: console.log('title', variable);
"semicolon" : true, // If false, will not add semicolon at end of line
"log_types" : ["log", "info", "warn", "error"]
},
"py": {
"consoleStr" : "{title}, {variable}",
"consoleFunc" : ["print"],
"single_quotes": false
},
"php": {
"consoleFunc" : ["print_r"], // var_dump or if you have custom logger ["$logger", "debug"] output: $logger->debug($variable);
"preTag" : true, // Put log in pre tag like echo '<pre>'; print_r($variable); echo '</pre>';
"dieAfterLog" : false // echo '<pre>'; print_r($variable); echo '</pre>'; die();
},
"fileTypeMap" : { // Maps file type to wrapper. For example "text.html.vue": "js" means use js wrapper in vue js files
"text.html.vue" : "js", // php,python,js is included by dafault ("embedding.php": "php", "source.js": "js", "source.python": "py")
"source.ts" : "js",
"source.tsx" : "js",
"source.coffee" : "js",
"text.html.basic": "js",
"text.html.blade": "js",
"text.html.twig" : "js"
}
"js": {
"consoleStr" : "{title}, {variable}", // "{title}, tmpVal = {variable}" to assigne value to temporary parameter output: console.log('title', tmpVal = variable);
"consoleFunc" : ["console", "log"], // You can change default log statement for example ["logger", "info"] output: logger.info('title', variable);
"single_quotes": false, // If true output: console.log('title', variable);
"semicolon" : true, // If false, will not add semicolon at end of line
"log_types" : ["log", "info", "warn", "error"]
},
"py": {
"consoleStr" : "{title}, {variable}",
"consoleFunc" : ["print"],
"single_quotes": false
},
"php": {
"consoleFunc" : ["print_r"], // var_dump or if you have custom logger ["$logger", "debug"] output: $logger->debug($variable);
"preTag" : true, // Put log in pre tag like echo '<pre>'; print_r($variable); echo '</pre>';
"dieAfterLog" : false // echo '<pre>'; print_r($variable); echo '</pre>'; die();
},
"fileTypeMap" : { // Maps file type to wrapper. For example "text.html.vue": "js" means use js wrapper in vue js files
"text.html.vue" : "js", // php,python,js is included by dafault ("embedding.php": "php", "source.js": "js", "source.python": "py")
"source.ts" : "js",
"source.tsx" : "js",
"source.coffee" : "js",
"text.html.basic": "js",
"text.html.blade": "js",
"text.html.twig" : "js"
}
}
152 changes: 76 additions & 76 deletions console_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
import sublime_plugin

try:
from .core.tools import *
from .core.settings import *
from .core.js_wrapper import JsWrapp
from .core.py_wrapper import PyWrapp
from .core.php_wrapper import PhpWrapp
from .core.tools import *
from .core.settings import *
from .core.js_wrapper import JsWrapp
from .core.py_wrapper import PyWrapp
from .core.php_wrapper import PhpWrapp
except ValueError:
from core.tools import *
from core.settings import *
from core.js_wrapper import JsWrapp
from core.py_wrapper import PyWrapp
from core.php_wrapper import PhpWrapp
from core.tools import *
from core.settings import *
from core.js_wrapper import JsWrapp
from core.py_wrapper import PyWrapp
from core.php_wrapper import PhpWrapp


def plugin_loaded():
print('[Console Wrap] ' + '*' * 30 + ' loaded ' + '*' * 30)
print('[Console Wrap] ' + '*' * 30 + ' loaded ' + '*' * 30)


wrapConnector = {}
Expand All @@ -27,98 +27,98 @@ def plugin_loaded():


def getFileTypeMap():
fileTypeMap = settings().get('fileTypeMap') or {
"text.html.vue": "js",
"source.ts": "js",
"source.tsx": "js",
"source.coffee": "js",
"text.html.basic": "js",
"text.html.blade": "js",
"text.html.twig": "js"
}
defMap = {
"embedding.php": "php",
"source.js": "js",
"source.python": "py"
}
fileTypeMap.update(defMap)
return fileTypeMap
fileTypeMap = settings().get('fileTypeMap') or {
"text.html.vue": "js",
"source.ts": "js",
"source.tsx": "js",
"source.coffee": "js",
"text.html.basic": "js",
"text.html.blade": "js",
"text.html.twig": "js"
}
defMap = {
"embedding.php": "php",
"source.js": "js",
"source.python": "py"
}
fileTypeMap.update(defMap)
return fileTypeMap


def supportedFile(view):
supported = False
fileTypeMap = getFileTypeMap()
supported = False
fileTypeMap = getFileTypeMap()

cursors = view.sel()
cursors = view.sel()

if not list(cursors):
view.sel().add(0)
if not list(cursors):
view.sel().add(0)

for cursor in cursors:
scope_name = view.scope_name(cursor.begin())
fileTypeIntersect = list(set(scope_name.split(' ')).intersection(fileTypeMap))
for cursor in cursors:
scope_name = view.scope_name(cursor.begin())
fileTypeIntersect = list(set(scope_name.split(' ')).intersection(fileTypeMap))

if fileTypeIntersect:
supported = True
if fileTypeIntersect:
supported = True

return supported
return supported


def runCommand(view, edit, action, insert_before=False):
cursors = view.sel()
cursors = view.sel()

fileTypeMap = getFileTypeMap()
lastPos = float("inf")
fileTypeMap = getFileTypeMap()
lastPos = float("inf")

if not list(cursors):
view.sel().add(0)
if not list(cursors):
view.sel().add(0)

for cursor in cursors:
scope_name = view.scope_name(cursor.begin())
for cursor in cursors:
scope_name = view.scope_name(cursor.begin())

fileTypeIntersect = list(set(scope_name.split(' ')).intersection(fileTypeMap))[::-1]
fileTypeIntersect = list(set(scope_name.split(' ')).intersection(fileTypeMap))[::-1]

if not fileTypeIntersect:
fileType = scope_name.split(' ')[0]
msg = 'Console Wrap: Not work in this file type ( {} )'.format(fileType)
sublime.status_message(msg)
continue
if not fileTypeIntersect:
fileType = scope_name.split(' ')[0]
msg = 'Console Wrap: Not work in this file type ( {} )'.format(fileType)
sublime.status_message(msg)
continue

wrapperType = fileTypeMap.get(fileTypeIntersect[0], False)
wrapperType = fileTypeMap.get(fileTypeIntersect[0], False)

if view.match_selector(cursor.begin(), 'source.php'):
wrapperType = 'php'
if view.match_selector(cursor.begin(), 'source.php'):
wrapperType = 'php'

if view.match_selector(cursor.begin(), 'source.js'):
wrapperType = 'js'
if view.match_selector(cursor.begin(), 'source.js'):
wrapperType = 'js'

wrapper = wrapConnector.get(wrapperType, None)
wrapper = wrapConnector.get(wrapperType, None)

if wrapper:
if action == 'create':
end = getattr(wrapper, action)(view, edit, cursor, insert_before)
else:
end = getattr(wrapper, action)(view, edit, cursor)
if end:
lastPos = end if end < lastPos else lastPos
if wrapper:
if action == 'create':
end = getattr(wrapper, action)(view, edit, cursor, insert_before)
else:
end = getattr(wrapper, action)(view, edit, cursor)
if end:
lastPos = end if end < lastPos else lastPos

return lastPos
return lastPos


class ConsoleWrapCommand(sublime_plugin.TextCommand):
def run(self, edit, insert_before=False):
view = self.view
lastPos = runCommand(view, edit, 'create', insert_before)
def run(self, edit, insert_before=False):
view = self.view
lastPos = runCommand(view, edit, 'create', insert_before)

if lastPos > 0 and lastPos < float("inf"):
view.sel().clear()
view.sel().add(sublime.Region(lastPos, lastPos))
self.view.run_command("move_to", {"to": "eol"})
if lastPos > 0 and lastPos < float("inf"):
view.sel().clear()
view.sel().add(sublime.Region(lastPos, lastPos))
self.view.run_command("move_to", {"to": "eol"})


class ConsoleActionCommand(sublime_plugin.TextCommand):
def is_enabled(self):
return supportedFile(self.view)
def is_enabled(self):
return supportedFile(self.view)

def run(self, edit, action=False):
runCommand(self.view, edit, action)
def run(self, edit, action=False):
runCommand(self.view, edit, action)
Loading

0 comments on commit 2a53f3c

Please sign in to comment.