Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select text using douglas, rainbow, and legion #501

Merged
merged 14 commits into from
Jun 23, 2019

Conversation

seekM
Copy link
Contributor

@seekM seekM commented May 7, 2019

This PR allows for text selection using douglas and rainbow. There are three ways to select text (using douglas as an example here, rainbow is analogous):

  • long version: <x1> [by] <y1> select <x2> [by] <y2>
  • short version: <x1> [by] <y1> select <x2> (with an implicit y2 = y1 value). This is useful to select text which is on one horizontal line
  • point version: set two points first (point one, point two), then do a select. This allows for precise text selection. How to do it in detail? For the first point you can do <x1> [by] <y1> move, the fine-tune via curse. Then do point one. Then do the same for the second point, then select.

Furthermore I replaced Playback([(["mouse", "right", "click"], 0.0)]).execute() by Mouse("right").execute() (same for left click). This makes the code more language agnostic. Dragonfly offers a mouse action to drag the mouse, but it didn't work for me. Therefore I used win32api, win32con directly. Does grids.wait_for_death(settings.DOUGLAS_TITLE) work? I couldn't track down the respective setting / value and had to add time.sleep(0.1) at one point as a workaround.

@seekM seekM changed the title Select text using grid Select text using douglas and rainbow May 7, 2019
@LexiconCode LexiconCode added the Enhancement Enhancement of an existing feature label May 7, 2019
@kendonB kendonB added the Waiting for User Reply Waiting for OP reply label May 14, 2019
@LexiconCode
Copy link
Member

LexiconCode commented May 21, 2019

@seekM could you update the documentation.

@LexiconCode
Copy link
Member

@kendonB could you test this as well?

@seekM
Copy link
Contributor Author

seekM commented May 23, 2019

Unfortunately I'm busy with other things at the moment, I'll add documentation later.

@kendonB
Copy link
Collaborator

kendonB commented May 27, 2019

I've tried this and it works beautifully.

The process for the fine selection option should be explained a bit more clearly too.

Fantastic contribution, I am going to merge this one into my own copy right away.

kendonB pushed a commit to kendonB/Caster that referenced this pull request May 28, 2019
@kendonB kendonB changed the title Select text using douglas and rainbow Select text using douglas, rainbow, and legion May 29, 2019
@kendonB
Copy link
Collaborator

kendonB commented May 29, 2019

@seekM can you test my addition for legion?

@kendonB
Copy link
Collaborator

kendonB commented Jun 2, 2019

@seekM were you able to review my changes? please test the functionality of the Legion selection and take a look at my changes to the documentation. We will be able to merge after that.

@seekM
Copy link
Contributor Author

seekM commented Jun 3, 2019

Legion doesn't work for me at the moment, so I can't test it. Also when I tried to checkout this PR there were some errors which are due to the files in my Caster user folder I think. I don't have time to resovle them at the moment so it would be cool if someone else could review if necessary.

@kendonB
Copy link
Collaborator

kendonB commented Jun 3, 2019

Also when I tried to checkout this PR there were some errors which are due to the files in my Caster user folder I think.

Could you paste the errors here?

@seekM
Copy link
Contributor Author

seekM commented Jun 3, 2019

Ignoring ccr rule 'Navigation'. Failed to load with: 
<type 'exceptions.TypeError'>
executable argument must be a string or None; received ['rstudio', 'foxitreader']
<traceback object at 0x0F410288>
  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\__init__.py", line 35, in <module>
    [class_name])  # attempts to import the class

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 165, in <module>
    class Navigation(MergeRule):

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 229, in Navigation
    (AppContext(executable=["rstudio", "foxitreader"]), Key("cs-z")*Repeat(extra="nnavi10")),

  File "C:\dev\Python27\lib\site-packages\dragonfly\grammar\context.py", line 217, in __init__
    " received %r" % executable)

Ignoring ccr rule 'HTML'. Failed to load with: 
<type 'exceptions.TypeError'>
executable argument must be a string or None; received ['idea', 'idea64', 'studio64', 'pycharm', 'webstorm64', 'webstorm']
<traceback object at 0x0F9FB3A0>
  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\__init__.py", line 35, in <module>
    [class_name])  # attempts to import the class

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\html\html.py", line 11, in <module>
    context = AppContext(executable=["idea", "idea64", "studio64", "pycharm", "webstorm64", "webstorm"])

  File "C:\dev\Python27\lib\site-packages\dragonfly\grammar\context.py", line 217, in __init__
    " received %r" % executable)

Ignoring application 'eclipse'. Failed to load with: 
<type 'exceptions.TypeError'>
executable argument must be a string or None; received ['rstudio', 'foxitreader']
<traceback object at 0x108A8A08>
  File "C:\dev\Natlink-User\Caster\castervoice\apps\__init__.py", line 13, in is_valid
    _ = __import__(module, globals(), locals())

  File "C:\dev\Natlink-User\Caster\castervoice\apps\eclipse.py", line 15, in <module>
    from castervoice.lib.ccr.core.nav import Navigation

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 165, in <module>
    class Navigation(MergeRule):

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 229, in Navigation
    (AppContext(executable=["rstudio", "foxitreader"]), Key("cs-z")*Repeat(extra="nnavi10")),

  File "C:\dev\Python27\lib\site-packages\dragonfly\grammar\context.py", line 217, in __init__
    " received %r" % executable)

Ignoring application 'flashdevelop'. Failed to load with: 
<type 'exceptions.TypeError'>
executable argument must be a string or None; received ['rstudio', 'foxitreader']
<traceback object at 0x10AC9468>
  File "C:\dev\Natlink-User\Caster\castervoice\apps\__init__.py", line 13, in is_valid
    _ = __import__(module, globals(), locals())

  File "C:\dev\Natlink-User\Caster\castervoice\apps\flashdevelop.py", line 6, in <module>
    from castervoice.lib.ccr.core.nav import Navigation

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 165, in <module>
    class Navigation(MergeRule):

  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 229, in Navigation
    (AppContext(executable=["rstudio", "foxitreader"]), Key("cs-z")*Repeat(extra="nnavi10")),

  File "C:\dev\Python27\lib\site-packages\dragonfly\grammar\context.py", line 217, in __init__
    " received %r" % executable)

Error loading _caster from C:\dev\Natlink-User\Caster\_caster.py
Traceback (most recent call last):
  File "C:\dev\NatLink\NatLink\MacroSystem\core\natlinkmain.py", line 331, in loadFile
    imp.load_module(modName,fndFile,fndName,fndDesc)
  File "C:\dev\Natlink-User\Caster\_caster.py", line 44, in <module>
    import castervoice.lib.dev.dev
  File "C:\dev\Natlink-User\Caster\castervoice\lib\dev\__init__.py", line 1, in <module>
    import dev
  File "C:\dev\Natlink-User\Caster\castervoice\lib\dev\dev.py", line 21, in <module>
    from castervoice.lib.tests import testrunner
  File "C:\dev\Natlink-User\Caster\castervoice\lib\tests\testrunner.py", line 3, in <module>
    from castervoice.lib.tests.unit import merger, mergerule, filter, state, stack, node, textformat
  File "C:\dev\Natlink-User\Caster\castervoice\lib\tests\unit\merger.py", line 3, in <module>
    from castervoice.apps import eclipse
  File "C:\dev\Natlink-User\Caster\castervoice\apps\eclipse.py", line 15, in <module>
    from castervoice.lib.ccr.core.nav import Navigation
  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 165, in <module>
    class Navigation(MergeRule):
  File "C:\dev\Natlink-User\Caster\castervoice\lib\ccr\core\nav.py", line 229, in Navigation
    (AppContext(executable=["rstudio", "foxitreader"]), Key("cs-z")*Repeat(extra="nnavi10")),
  File "C:\dev\Python27\lib\site-packages\dragonfly\grammar\context.py", line 217, in __init__
    " received %r" % executable)
TypeError: executable argument must be a string or None; received ['rstudio', 'foxitreader']
-- skip unchanged wrong grammar file: C:\dev\Natlink-User\Caster\_caster.py
--- userLanguage: deu

-- skip unchanged wrong grammar file: C:\dev\Natlink-User\Caster\_caster.py
natlinkmain started from C:\dev\NatLink\NatLink\MacroSystem\core:

kendonB pushed a commit to kendonB/Caster that referenced this pull request Jun 3, 2019
@seekM
Copy link
Contributor Author

seekM commented Jun 5, 2019

Updating dragonfly2 made these errors go away

@LexiconCode
Copy link
Member

ready to merge?

@kendonB
Copy link
Collaborator

kendonB commented Jun 11, 2019

legion behavior needs testing by someone other than me for whom legion is working.

@kendonB
Copy link
Collaborator

kendonB commented Jun 11, 2019

I'd also like someone to review the documentation changes.

@kendonB kendonB added Needs Review A pull request needs a code review. and removed Waiting for User Reply Waiting for OP reply labels Jun 15, 2019
@kendonB kendonB self-assigned this Jun 15, 2019
- _red 86 kick_: - Clicks at this location.
- _two red 86_ - References square within the second red palette.
- _red 86 select 2 green 10_: - Selects from the first red 86 to the second green 10.
- _red 86, curse sauce lease 5, point one, select 2 green 10, curse dunce lease 10, point two, select_: - Selects from the first red 86 to the second green 10 with fine adjustment.
Copy link
Contributor

@codingApprentice codingApprentice Jun 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be ,
"red 86 move, curse sauce lease 5, point one, 2 green 10 move, curse dunce lease 10, point two, select"
in the 5th example for rainbow?
Everything else in the documentation seems fine. I tested it and the selection examples seem to work for rainbow Douglas and Legion.
Although, note, I have only one screen, so I couldn't test it with multiple screens.

Copy link
Contributor

@codingApprentice codingApprentice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed documentation changes, and these usage examples for rainbow Douglas and Legion seem to work, except for the 5th example in rainbow, just a typo. See my comment on the line change.
Note: I only have one screen. So I can't comment on the multiscreen functionality.

@shervinemami
Copy link

Nice work guys! I implemented a similar feature in recent weeks using Aenea on Linux based on Caster's Douglas grid, I haven't submitted it to the Caster project because my method currently only supports Linux + Aenea, but I've been using it about 50 times per day and it's been very useful! I just thought I'd mention that instead of your "point 1" & "point 2" keywords, you might like to use the keywords "drag" & "release", if you find it more intuitive? In my BeamGrid system I move the mouse to a starting point, I say "drag", then move to the end point, then say "release".

@kendonB
Copy link
Collaborator

kendonB commented Jun 16, 2019

@codingApprentice, good catch and thanks for having a look!

@shervinemami, great point; note that the caster commands "squat" and "bench" are used for holding and releasing the left mouse button.

Since Caster now supports Aenea (or is trying to) it would be great for you to to add your code here! The mouse grids / legion are the only thing preventing me from trying out Caster with Aenea at this point.

@kendonB
Copy link
Collaborator

kendonB commented Jun 16, 2019

I don't see any value in using "point two, select" instead of using "bench" for both. Can anyone think of a reason to keep them separate?

@kendonB
Copy link
Collaborator

kendonB commented Jun 16, 2019

Can we talk about what we think the default behavior should be? I think the default should act like legion does which is to move the cursor and close the mouse application without clicking. I am going to change douglas and rainbow to this behavior unless there are objections.

kendonB added a commit to kendonB/Caster that referenced this pull request Jun 23, 2019
kendonB added a commit to kendonB/Caster that referenced this pull request Jun 23, 2019
kendonB added a commit to kendonB/Caster that referenced this pull request Jun 23, 2019
@LexiconCode
Copy link
Member

ready to merge?

@LexiconCode LexiconCode added Documentation Needed Issue needs grammars or function documentation and removed Needs Review A pull request needs a code review. labels Jun 23, 2019
@shervinemami
Copy link

Since Caster now supports Aenea (or is trying to) it would be great for you to to add your code here! The mouse grids / legion are the only thing preventing me from trying out Caster with Aenea at this point.

Oh I didn't know Caster is trying to support Aenea. I'll discuss that on the gitter forum.

@kendonB kendonB merged commit 9acf836 into dictation-toolbox:develop Jun 23, 2019
@kendonB kendonB added Complete Pull request is complete and tested as defined by Contributor and removed Documentation Needed Issue needs grammars or function documentation labels Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complete Pull request is complete and tested as defined by Contributor Enhancement Enhancement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants