Skip to content

Commit

Permalink
Renamed glyph_scope to literal_scope
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Dec 8, 2023
1 parent d426a66 commit 4ed60fb
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 66 deletions.
10 changes: 5 additions & 5 deletions cursorless-talon/src/cheatsheet/sections/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"previous_next_modifier",
"forward_backward_modifier",
"position",
"glyph_modifier",
"literal_modifier",
]


Expand All @@ -29,7 +29,7 @@ def get_modifiers():
"next",
"backward",
"forward",
"glyph",
"literal",
]
simple_modifiers = {
key: value
Expand Down Expand Up @@ -104,12 +104,12 @@ def get_modifiers():
],
},
{
"id": "glyph",
"id": "literal",
"type": "modifier",
"variations": [
{
"spokenForm": f"{complex_modifiers['glyph']} <glyph>",
"description": "First instance of <glyph>",
"spokenForm": f"{complex_modifiers['literal']} <literal>",
"description": "First instance of <literal>",
},
],
},
Expand Down
30 changes: 0 additions & 30 deletions cursorless-talon/src/modifiers/glyph_scope.py

This file was deleted.

30 changes: 30 additions & 0 deletions cursorless-talon/src/modifiers/literal_scope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from talon import Module

mod = Module()

mod.list(
"cursorless_literal_scope_type",
desc="Cursorless literal scope type",
)
mod.list(
"cursorless_literal_scope_type_plural",
desc="Plural version of Cursorless literal scope type",
)


@mod.capture(rule="{user.cursorless_literal_scope_type} <user.any_alphanumeric_key>")
def cursorless_literal_scope_type(m) -> dict[str, str]:
return {
"type": "literal",
"literal": m.any_alphanumeric_key,
}


@mod.capture(
rule="{user.cursorless_literal_scope_type_plural} <user.any_alphanumeric_key>"
)
def cursorless_literal_scope_type_plural(m) -> dict[str, str]:
return {
"type": "literal",
"literal": m.any_alphanumeric_key,
}
8 changes: 4 additions & 4 deletions cursorless-talon/src/modifiers/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@mod.capture(
rule="{user.cursorless_scope_type} | <user.cursorless_glyph_scope_type> | {user.cursorless_custom_regex_scope_type}"
rule="{user.cursorless_scope_type} | <user.cursorless_literal_scope_type> | {user.cursorless_custom_regex_scope_type}"
)
def cursorless_scope_type(m) -> dict[str, str]:
"""Cursorless scope type singular"""
Expand All @@ -25,15 +25,15 @@ def cursorless_scope_type(m) -> dict[str, str]:
pass

try:
return m.cursorless_glyph_scope_type
return m.cursorless_literal_scope_type
except AttributeError:
pass

return {"type": "customRegex", "regex": m.cursorless_custom_regex_scope_type}


@mod.capture(
rule="{user.cursorless_scope_type_plural} | <user.cursorless_glyph_scope_type_plural> | {user.cursorless_custom_regex_scope_type_plural}"
rule="{user.cursorless_scope_type_plural} | <user.cursorless_literal_scope_type_plural> | {user.cursorless_custom_regex_scope_type_plural}"
)
def cursorless_scope_type_plural(m) -> dict[str, str]:
"""Cursorless scope type plural"""
Expand All @@ -43,7 +43,7 @@ def cursorless_scope_type_plural(m) -> dict[str, str]:
pass

try:
return m.cursorless_glyph_scope_type_plural
return m.cursorless_literal_scope_type_plural
except AttributeError:
pass

Expand Down
4 changes: 2 additions & 2 deletions cursorless-talon/src/spoken_forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@
"surrounding_pair_scope_type": {
"string": "string"
},
"glyph_scope_type": {
"glyph": "glyph"
"literal_scope_type": {
"glyph": "literal"
}
},
"paired_delimiters.csv": {
Expand Down
4 changes: 2 additions & 2 deletions cursorless-talon/src/spoken_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def ret(filename: str, *args: P.args, **kwargs: P.kwargs) -> R:
"wrapper_only_paired_delimiter": "pairedDelimiter",
"surrounding_pair_scope_type": "pairedDelimiter",
"scope_type": "simpleScopeTypeType",
"glyph_scope_type": "complexScopeTypeType",
"literal_scope_type": "complexScopeTypeType",
"custom_regex_scope_type": "customRegex",
}

Expand Down Expand Up @@ -126,7 +126,7 @@ def handle_new_values(csv_name: str, values: list[SpokenFormEntry]):
handle_csv("experimental/miscellaneous.csv"),
handle_csv(
"modifier_scope_types.csv",
pluralize_lists=["scope_type", "glyph_scope_type"],
pluralize_lists=["scope_type", "literal_scope_type"],
extra_allowed_values=[
"private.fieldAccess",
"private.switchStatementSubject",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@ export interface OneOfScopeType {
scopeTypes: ScopeType[];
}

export interface GlyphScopeType {
type: "glyph";
character: string;
export interface LiteralScopeType {
type: "literal";
literal: string;
}

export type ScopeType =
| SimpleScopeType
| SurroundingPairScopeType
| CustomRegexScopeType
| OneOfScopeType
| GlyphScopeType;
| LiteralScopeType;

export interface ContainingSurroundingPairModifier
extends ContainingScopeModifier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ export class PrimitiveTargetSpokenFormGenerator {
switch (scopeType.type) {
case "oneOf":
throw new NoSpokenFormError(`Scope type '${scopeType.type}'`);
case "glyph":
case "literal":
return [
this.spokenFormMap.complexScopeTypeType.glyph,
characterToSpokenForm(scopeType.character),
this.spokenFormMap.complexScopeTypeType.literal,
characterToSpokenForm(scopeType.literal),
];
case "surroundingPair": {
const pair = this.spokenFormMap.pairedDelimiter[scopeType.delimiter];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CustomRegexScopeType,
Direction,
GlyphScopeType,
LiteralScopeType,
ScopeType,
} from "@cursorless/common";
import { imap } from "itertools";
Expand Down Expand Up @@ -69,14 +69,14 @@ export class CustomRegexScopeHandler extends RegexStageBase {
}
}

export class GlyphScopeHandler extends RegexStageBase {
export class LiteralScopeHandler extends RegexStageBase {
get regex() {
return new RegExp(escapeRegExp(this.scopeType.character), "gui");
return new RegExp(escapeRegExp(this.scopeType.literal), "gui");
}

constructor(
scopeHandlerFactory: ScopeHandlerFactory,
readonly scopeType: GlyphScopeType,
readonly scopeType: LiteralScopeType,
languageId: string,
) {
super(scopeHandlerFactory, scopeType, languageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { OneOfScopeHandler } from "./OneOfScopeHandler";
import { ParagraphScopeHandler } from "./ParagraphScopeHandler";
import {
CustomRegexScopeHandler,
GlyphScopeHandler,
LiteralScopeHandler,
NonWhitespaceSequenceScopeHandler,
UrlScopeHandler,
} from "./RegexScopeHandler";
Expand Down Expand Up @@ -73,8 +73,8 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
return new UrlScopeHandler(this, scopeType, languageId);
case "customRegex":
return new CustomRegexScopeHandler(this, scopeType, languageId);
case "glyph":
return new GlyphScopeHandler(this, scopeType, languageId);
case "literal":
return new LiteralScopeHandler(this, scopeType, languageId);
case "custom":
return scopeType.scopeHandler;
case "instance":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function isLanguageSpecific(scopeType: ScopeType): boolean {
case "notebookCell":
case "surroundingPair":
case "customRegex":
case "glyph":
case "literal":
return false;

case "oneOf":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
export interface SpokenFormMapKeyTypes {
pairedDelimiter: SpeakableSurroundingPairName;
simpleScopeTypeType: SimpleScopeTypeType;
complexScopeTypeType: "glyph";
complexScopeTypeType: "literal";
surroundingPairForceDirection: "left" | "right";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = {
["private.switchStatementSubject"]: isPrivate("subject"),
},
complexScopeTypeType: {
glyph: "glyph",
literal: "glyph",
},

surroundingPairForceDirection: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command:
type: primitive
modifiers:
- type: everyScope
scopeType: {type: glyph, character: a}
scopeType: {type: literal, literal: a}
usePrePhraseSnapshot: true
initialState:
documentContents: abc$!4123a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command:
type: primitive
modifiers:
- type: ordinalScope
scopeType: {type: glyph, character: a}
scopeType: {type: literal, literal: a}
start: -1
length: 1
usePrePhraseSnapshot: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: glyph, character: a}
scopeType: {type: literal, literal: a}
usePrePhraseSnapshot: true
initialState:
documentContents: abc$!4123a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command:
type: primitive
modifiers:
- type: relativeScope
scopeType: {type: glyph, character: b}
scopeType: {type: literal, literal: b}
offset: 1
length: 1
direction: forward
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command:
type: primitive
modifiers:
- type: relativeScope
scopeType: {type: glyph, character: $}
scopeType: {type: literal, literal: $}
offset: 1
length: 1
direction: forward
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ command:
type: primitive
modifiers:
- type: relativeScope
scopeType: {type: glyph, character: å}
scopeType: {type: literal, literal: å}
offset: 1
length: 1
direction: forward
Expand Down

0 comments on commit 4ed60fb

Please sign in to comment.