enjalot / Inlet

Bret Victor inspired slider & color picker plugin for CodeMirror
http://enjalot.github.com/Inlet
Other
74 stars 11 forks source link

Less history entry when changing color #22

Open ArkadiuszMichalski opened 9 years ago

ArkadiuszMichalski commented 9 years ago

Is there any way to shut down CM history modyfication when changing color by Inlet? Now is really hard backing to starting (original) value, because all actions (new color) is remember by CM and after setting new value we must press many times "Ctrl+Z" < undo.

Will be better if Inlet will return new color value (last) to CM only when we close slider and output actual changing value (text) to somwhere in slider.

georules commented 9 years ago

This is a good point since it seems that codemirror seems to keep a pretty small history. I tried to mockup this functionality for changing hex colors, getting the history on a hex match and restoring the history to that point when there is another click into the editor. It has some problems though:

1) it does not include the original value of the hex color before you pick a new one 2) if you press control z before restoring (getting focus back into the editor) control z will go back in the history of colors 3) clicking to remove the thistle color picker does not restore focus to codemirror, and then requires another click in the editor before the history is restored.

In case anyone is interested in tackling this or has ideas, here is my attempt as perhaps a starting place:

storing history: https://github.com/georules/Inlet/commit/53537ea222eb9c08feeec145d985e73bf0d7a50d#diff-f3d2729ea93f0b72d03a02dd99adf6c9R177

reverting history: https://github.com/georules/Inlet/commit/53537ea222eb9c08feeec145d985e73bf0d7a50d#diff-f3d2729ea93f0b72d03a02dd99adf6c9L234

https://github.com/georules/Inlet/tree/history https://codemirror.net/doc/manual.html#api_history

enjalot commented 9 years ago

We want to change the actual text in CodeMirror on every color choice so that we see it render as we change. The immediate feedback is a key feature.

I do agree that having a way to "undo" your playing around would be a useful feature. I don't know that restoring when you click in the editor is good because thats one of the main ways to close the editor, what if you want to keep the color?

georules commented 9 years ago

It's restoring the history before the color-scrubbing, not the text presently in the editor. The text would stay as you selected it, but not have the history of the many color selections you made along the way, so undo is closer to points where you actually typed. (at least I think this is what was being requested)

enjalot commented 9 years ago

oooh, so by manipulating the history you're still making the changes with each selection, but when you are done you can easily undo to the previous value. :+1:

On Fri, Sep 11, 2015 at 2:14 PM, Geoffery Miller notifications@github.com wrote:

It's restoring the history before the color-scrubbing, not the text. The text would stay as you selected it, but not have the history of the many color selections you made along the way, so undo is closer to points where you actually typed. (at least I think this is what was being requested)

— Reply to this email directly or view it on GitHub https://github.com/enjalot/Inlet/issues/22#issuecomment-139662716.

Ian Johnson - 周彦 http://enja.org

georules commented 9 years ago

Yeah I think to implement this we'd need to at least fix:

1) have the next control-z after scrubbing be the color be before scrubbing 2) restore history on scrubber blur rather than editor refocus