fregante / GhostText

👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).
https://GhostText.fregante.com
MIT License
3.25k stars 116 forks source link

How to disconnect the field on the new GhostText? #178

Open fregante opened 3 years ago

fregante commented 3 years ago

Originally posted by @subnut in https://github.com/GhostText/GhostText/issues/172#issuecomment-735098823:

If a field is currently connected, then clicking the GhostText extension icon and selecting the connected field should disconnect it.

Yeah the current disconnection logic isn't super clear. In the previous version you would just click the button again and it would disconnect, but now it just looks for more fields.

So the solution I came up with is to right click the button 😬 or to just close the editor tab (which would make more sense, since you're done with it so you want to go back to the browser)

Does anyone have any suggestions for an intuitive way to disconnect the editor from the browser?

subnut commented 3 years ago

I think that the current method is sufficient... but I think that it would be more intuitive if clicking on the extension caused us to enter Toggle mode instead of Register new element mode. i.e. Clicking on an already-enabled field should disable it, and clicking on a non-enabled field should enable it

llinfeng commented 3 years ago

@fregante Ideas to disconnect:

  1. How about adding another keyboard shortcut to disconnect? From a couple of months ago, I recall hitting the same (and only) shortcut shall toggle the text fields on and off. For now, hitting the shortcut for "Connect to GhostText" no longer disconnects. The downside is that now we need to remember another key-binding.

  2. Personally, I would prefer having an option with the add-on that restores the old behavior. Maybe we can call it "toggle mode"? With one single shortcut, I enter and edit, and hit it again when done. I use GhostText mostly with Jupyter notebooks.

fregante commented 3 years ago
  1. How about adding another keyboard shortcut to disconnect

I like that. Keyboard shortcuts are cheap, as long as I can register an action without setting a default shortcut (so it's up to the user to customize it)

2. I would prefer having an option with the add-on that restores the old behavior

I feel you, the simplicity was good. I wonder if that should be the regular behavior, while still allowing multiple fields by:

However this would mean that the first Activation would work one way, and the next activations would work differently… a bit confusing.

fregante commented 3 years ago

Makes me wonder if GT should exclusively handle focused fields:

That's it. Simple. No field focused = do nothing.

You must select the field first and then you activate GhostText. This should simplify the code too, because there's no more "Focus (another) field to activate" state.

Perhaps with an additional behavior:

Full flow chart: https://user-images.githubusercontent.com/1402241/108940258-a2598300-7618-11eb-902f-b704c5a02c5a.png

llinfeng commented 3 years ago

There is definitely a great value in allowing multiple focus+connections and keeping the editor busy syncing up with all the input fields. Along with the gorgeous flow chart, I can see myself rearranging the tabs and panes opened in the editor to make use of the multiple simultaneous connections. Two concerns, though:

  1. Practically, how stable are the connections? I managed to crash the Firefox add-on with vim-ghost, where I was clicking on multiple cells in a Jupyterlab notebook: each cell opened a new buffer (with a temp file name) in Vim but the connection quickly stumbled and crashed. With the Chrome extension, I managed to crash the extension by "double-clicking" on the same imput field on this Github page. (I should have pressed the "Connect to Ghost Text" shortcut in between the "double-clicking".
  2. More practically, well: for those who can make good use of the multiple focus+connection pairs, do they really need to keep multiple pairs open at the same time? I am thinking in the context of Jupyter notebooks, which is popular among data scientists: if one opts to go for production, instead of editing multiple cells in a .ipynb notebook simultaneously with an editor, well, it is advised to write modularized code in .py scripts.

I suppose I can be terribly wrong with the second concern.


By the way, is there an archive of older versions for the Firefox add-on? The versions on this page seem incomplete?

I see myself doing one-off edits mostly, where I only need one input field to activate. When I am done editing, it helps to disconnect GhostText add-on to keep all things back to normal. By now, I may have talked myself to vote for an extra option for a "toggle mode": when activated, the "Connect to GhostText" shortcut does two things below,

  1. When there is no connection, activate all the candidate fields and wait for a mouseclick
  2. When there is an existing connection, disconnect.

If I may recall, is this how GhostText has been working for years? However, I cannot find a newer version between December 2017 and Feb 2021 on the Firefox add-on page. The latest version back in 2017 is Version 17.12.11.910, and it does not allow me to assign a keyboard shortcut to "toggle" the add-on. I'll post a short Autohotkey script if I shall manage to assign a shortcut by clicking on the ghost-icon.


Here is some AHK script that looks for this tiny icon and moves the mouse onto it. To trigger it, use Gosub, icon_search_GhostTextFirefox.

icon_search_GhostTextFirefox:
    CoordMode, Pixel, Screen  
    CoordMode, Mouse, Screen 
    ; Note, for now, the search canvas is 5600 pixels wide and 2000 pixels tall
    ImageSearch, FoundX, FoundY, 0, 0, 5600, 2000,  icon_library\GhostText_firefox.png
    ; Update the cursor location by a few more pixels
    FoundX := FoundX + 20
    FoundY := FoundY + 14
    sleep 50
    if (ErrorLevel = 2)
        MsgBox Could not conduct the search.
    else if (ErrorLevel = 1)
        MsgBox Did not find such button.
    else
        MouseMove, %FoundX%, %FoundY%
return
fregante commented 1 year ago

Right-clicking is a bit awkward and doesn't work when the icon is in a menu on Safari (it used to be the same in Chrome, but they added hamburgers now)

Screenshot

I think GhostText should have a minimal UI to allow disconnection. This would appear sticky on the page:

225006670-b8294791-1344-42e2-bd42-dcdd9bfa923e

The only concern is integrating it with the notifications. Maybe: