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

Simple text expander for "New Dweet" editor #391

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

imscary
Copy link
Contributor

@imscary imscary commented Sep 6, 2018

Simple text expander to make a dweet more easy.

  • 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 imscary changed the title Textexp Simple text expander for "New Dweet" editor Sep 6, 2018
@lionleaf
Copy link
Owner

lionleaf commented Sep 8, 2018

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?

@sigvef
Copy link
Collaborator

sigvef commented Sep 8, 2018

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.

@imscary
Copy link
Contributor Author

imscary commented Sep 8, 2018

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

@imscary
Copy link
Contributor Author

imscary commented Sep 8, 2018

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
Copy link
Contributor Author

imscary commented Apr 7, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants