dwitter icon indicating copy to clipboard operation
dwitter copied to clipboard

Simple text expander for "New Dweet" editor

Open imscary opened this issue 7 years ago • 5 comments
trafficstars

Simple text expander to make a dweet more easy.

  • [x] Linted

hsl; becomes `hsl(${},99%,50%)`; hsla; becomes `hsla(${},99%,50%,.5)`; x.fs= becomes x.fillStyle= x.ss= becomes x.strokeStyle= x.fr becomes x.fillRect( x.bp; becomes x.beginPath(); x.fl; becomes x.fill(); x.sk; becomes x.stroke(); x.sr becomes x.strokeRect( clear; becomes c.width^=0; middle; becomes x.translate(960,540); 1time becomes t?0:event; x.gcop= becomes x.globalCompositeOperation= x.dri becomes x.drawImage(c,0,0) m.ab becomes Math.abs() m.rn becomes Math.random() ..rb gives random choice between 1 and 0 ..for becomes for(i=0;i++<10;) gr1 becomes α gr2 becomes β gr3 becomes θ gr4 becomes τ gr5 becomes λ ; becomes ; double space becomes ,

It really helped me. I created d/9685, d/9684, d/9683, d/9682, d/9681 using that script.

Improve the not working expands.

imscary avatar Sep 06 '18 14:09 imscary

As mentioned on discord, I think having fully automatic autocomplete might surprise people. If we're adding this feature I think it should be triggered by a keystroke, tab being the most obvious one. Can you make it into a tab-completion feature?

You might have to change the behaviour slightly for that. For instance,

x.f => x.fill, x.fillR => x.fillRect etc.

This might be slightly misleading as people might expect a full tab completion for all the members (rather than hardcoded), but is still quite useful.

That being said, dweets are very short already, so typing speed isn't really a major issue.

What do other frequent dweeters think of this?

lionleaf avatar Sep 08 '18 01:09 lionleaf

First off I think this is a really cool workflow! And I can see it being very comfortable and efficient for someone who is well-acquainted with the system. I agree with the points that lionleaf raises, and think that having an autocomplete feature more akin to traditional IDEs could be pretty sweet.

sigvef avatar Sep 08 '18 08:09 sigvef

It is just a structure of a basic expander. If I have time, I will make it really advanced and more performant 😄

imscary avatar Sep 08 '18 09:09 imscary

I set the expand key to (1 space) because it is the best choice here. It is easy and I'm sure ; + space isn't so frequent. It can be changed in the localStorage (key: "expandKey"). The x.fr = x.fillr = x.fillRe = x.fillRect is pretty tricky here... I think that the autocomplete feature isn't so good idea here because we need strict snippets to avoid misexpands (example: x.f = x.fillRect() or x.fill(), Math.a = Math.abs() or Math.acos())

imscary avatar Sep 08 '18 10:09 imscary

The tab trigger can't be used here without massive textbox event modifier script. Tab will only shift the html element selection, for example while editing and pressing tab, it will select the caption textbox. I can make the trigger to double spacebar. Also there is a bug:

    var start = c.selectionStart,
    	end = c.selectionEnd;
    c.setSelectionRange(start, end);

This will cancel any selection every call of the function in the loop. The script is also newbie maked, just a prototype and concept. I am going to make a good one the next week.

imscary avatar Apr 07 '19 08:04 imscary