From f26ad4c3953c8b73b1f1d8b7f00dcde5624967f8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 2 Dec 2021 00:12:48 +0100 Subject: [PATCH 1/2] Added column selection type --- src/modifiers/containing_scope.py | 181 +++++++++++++++--------------- 1 file changed, 91 insertions(+), 90 deletions(-) diff --git a/src/modifiers/containing_scope.py b/src/modifiers/containing_scope.py index 63a625df..bed82034 100644 --- a/src/modifiers/containing_scope.py +++ b/src/modifiers/containing_scope.py @@ -1,90 +1,91 @@ -from talon import Module, app -from ..csv_overrides import init_csv_and_watch_changes - -mod = Module() - - -mod.list("cursorless_scope_type", desc="Supported scope types") - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -scope_types = { - "arg": "argumentOrParameter", - "attribute": "attribute", - "call": "functionCall", - "class name": "className", - "class": "class", - "comment": "comment", - "funk name": "functionName", - "funk": "namedFunction", - "if state": "ifStatement", - "item": "collectionItem", - "key": "collectionKey", - "lambda": "anonymousFunction", - "list": "list", - "map": "map", - "name": "name", - "regex": "regularExpression", - "state": "statement", - "string": "string", - "type": "type", - "value": "value", - "condition": "condition", - # XML, JSX - "element": "xmlElement", - "tags": "xmlBothTags", - "start tag": "xmlStartTag", - "end tag": "xmlEndTag", -} - - -@mod.capture(rule="[every] {user.cursorless_scope_type}") -def cursorless_containing_scope(m) -> str: - """Expand to containing scope""" - return { - "modifier": { - "type": "containingScope", - "scopeType": m.cursorless_scope_type, - "includeSiblings": m[0] == "every", - } - } - - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -selection_types = { - "block": "paragraph", - "cell": "notebookCell", - "file": "document", - "line": "line", - "token": "token", -} - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -subtoken_scope_types = { - "word": "word", - "char": "character", -} - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -# NB: This is a hack until we support having inside and outside on arbitrary -# scope types -surrounding_pair_scope_types = { - "string": "string", -} - -default_values = { - "scope_type": scope_types, - "selection_type": selection_types, - "subtoken_scope_type": subtoken_scope_types, - "surrounding_pair_scope_type": surrounding_pair_scope_types, -} - - -def on_ready(): - init_csv_and_watch_changes("modifier_scope_types", default_values) - - -app.register("ready", on_ready) +from talon import Module, app +from ..csv_overrides import init_csv_and_watch_changes + +mod = Module() + + +mod.list("cursorless_scope_type", desc="Supported scope types") + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +scope_types = { + "arg": "argumentOrParameter", + "attribute": "attribute", + "call": "functionCall", + "class name": "className", + "class": "class", + "comment": "comment", + "funk name": "functionName", + "funk": "namedFunction", + "if state": "ifStatement", + "item": "collectionItem", + "key": "collectionKey", + "lambda": "anonymousFunction", + "list": "list", + "map": "map", + "name": "name", + "regex": "regularExpression", + "state": "statement", + "string": "string", + "type": "type", + "value": "value", + "condition": "condition", + # XML, JSX + "element": "xmlElement", + "tags": "xmlBothTags", + "start tag": "xmlStartTag", + "end tag": "xmlEndTag", +} + + +@mod.capture(rule="[every] {user.cursorless_scope_type}") +def cursorless_containing_scope(m) -> str: + """Expand to containing scope""" + return { + "modifier": { + "type": "containingScope", + "scopeType": m.cursorless_scope_type, + "includeSiblings": m[0] == "every", + } + } + + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +selection_types = { + "block": "paragraph", + "cell": "notebookCell", + "file": "document", + "line": "line", + "token": "token", + "column": "column" +} + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +subtoken_scope_types = { + "word": "word", + "char": "character", +} + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +# NB: This is a hack until we support having inside and outside on arbitrary +# scope types +surrounding_pair_scope_types = { + "string": "string", +} + +default_values = { + "scope_type": scope_types, + "selection_type": selection_types, + "subtoken_scope_type": subtoken_scope_types, + "surrounding_pair_scope_type": surrounding_pair_scope_types, +} + + +def on_ready(): + init_csv_and_watch_changes("modifier_scope_types", default_values) + + +app.register("ready", on_ready) From 5043b4a17dc067d6a315034560986274f520dd10 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 2 Dec 2021 09:08:28 +0100 Subject: [PATCH 2/2] Updated line ending --- src/modifiers/containing_scope.py | 182 +++++++++++++++--------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/src/modifiers/containing_scope.py b/src/modifiers/containing_scope.py index bed82034..9817e07e 100644 --- a/src/modifiers/containing_scope.py +++ b/src/modifiers/containing_scope.py @@ -1,91 +1,91 @@ -from talon import Module, app -from ..csv_overrides import init_csv_and_watch_changes - -mod = Module() - - -mod.list("cursorless_scope_type", desc="Supported scope types") - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -scope_types = { - "arg": "argumentOrParameter", - "attribute": "attribute", - "call": "functionCall", - "class name": "className", - "class": "class", - "comment": "comment", - "funk name": "functionName", - "funk": "namedFunction", - "if state": "ifStatement", - "item": "collectionItem", - "key": "collectionKey", - "lambda": "anonymousFunction", - "list": "list", - "map": "map", - "name": "name", - "regex": "regularExpression", - "state": "statement", - "string": "string", - "type": "type", - "value": "value", - "condition": "condition", - # XML, JSX - "element": "xmlElement", - "tags": "xmlBothTags", - "start tag": "xmlStartTag", - "end tag": "xmlEndTag", -} - - -@mod.capture(rule="[every] {user.cursorless_scope_type}") -def cursorless_containing_scope(m) -> str: - """Expand to containing scope""" - return { - "modifier": { - "type": "containingScope", - "scopeType": m.cursorless_scope_type, - "includeSiblings": m[0] == "every", - } - } - - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -selection_types = { - "block": "paragraph", - "cell": "notebookCell", - "file": "document", - "line": "line", - "token": "token", - "column": "column" -} - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -subtoken_scope_types = { - "word": "word", - "char": "character", -} - -# NOTE: Please do not change these dicts. Use the CSVs for customization. -# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md -# NB: This is a hack until we support having inside and outside on arbitrary -# scope types -surrounding_pair_scope_types = { - "string": "string", -} - -default_values = { - "scope_type": scope_types, - "selection_type": selection_types, - "subtoken_scope_type": subtoken_scope_types, - "surrounding_pair_scope_type": surrounding_pair_scope_types, -} - - -def on_ready(): - init_csv_and_watch_changes("modifier_scope_types", default_values) - - -app.register("ready", on_ready) +from talon import Module, app +from ..csv_overrides import init_csv_and_watch_changes + +mod = Module() + + +mod.list("cursorless_scope_type", desc="Supported scope types") + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +scope_types = { + "arg": "argumentOrParameter", + "attribute": "attribute", + "call": "functionCall", + "class name": "className", + "class": "class", + "comment": "comment", + "funk name": "functionName", + "funk": "namedFunction", + "if state": "ifStatement", + "item": "collectionItem", + "key": "collectionKey", + "lambda": "anonymousFunction", + "list": "list", + "map": "map", + "name": "name", + "regex": "regularExpression", + "state": "statement", + "string": "string", + "type": "type", + "value": "value", + "condition": "condition", + # XML, JSX + "element": "xmlElement", + "tags": "xmlBothTags", + "start tag": "xmlStartTag", + "end tag": "xmlEndTag", +} + + +@mod.capture(rule="[every] {user.cursorless_scope_type}") +def cursorless_containing_scope(m) -> str: + """Expand to containing scope""" + return { + "modifier": { + "type": "containingScope", + "scopeType": m.cursorless_scope_type, + "includeSiblings": m[0] == "every", + } + } + + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +selection_types = { + "block": "paragraph", + "cell": "notebookCell", + "file": "document", + "line": "line", + "token": "token", + "column": "column" +} + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +subtoken_scope_types = { + "word": "word", + "char": "character", +} + +# NOTE: Please do not change these dicts. Use the CSVs for customization. +# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md +# NB: This is a hack until we support having inside and outside on arbitrary +# scope types +surrounding_pair_scope_types = { + "string": "string", +} + +default_values = { + "scope_type": scope_types, + "selection_type": selection_types, + "subtoken_scope_type": subtoken_scope_types, + "surrounding_pair_scope_type": surrounding_pair_scope_types, +} + + +def on_ready(): + init_csv_and_watch_changes("modifier_scope_types", default_values) + + +app.register("ready", on_ready)