flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > vivik's twitter

Goto page Previous  1, 2, 3 ... , 13, 14, 15  Next
Author
Thread Post new topic Reply to topic
vivik



Joined: 29 Oct 2016
Posts: 669
welp, i broke this forum

EDIT: nvmd, it's finally ok. It kept showing "no post available", forum kept thinking there were 14 pages when there was only 13. There already is a thread about it in Feedback: https://board.flatassembler.net/topic.php?t=20915

Hm, let's cause this to every thread on this board, why not? Heh, not now.

---
when bored, open wikipedia or something. Not sure what exactly though... Maybe some news?

---
so, set's work on synchronization and undo-redo history.

before that, learn to type characters. I commented out TranslateMessage, so getting characters is a bit more tricky... Eh, uncommenting it.

WM_CHAR

https://docs.microsoft.com/en-us/windows/desktop/inputdev/using-keyboard-input

---
renamed MsgProc to wWinMain_MsgProc, and ThreadProc to wWinMain_ThreadProc. Visual Studio sorts functions alphabetically in its popup list, and those three are very close in functionality, so, need to keep them closer together.

---
okay, now undo-redo history
then sync
hm, and maybe wordwrap before those two?

...
let's hack the rendering a bit. Make the "undo" buffer, and add your strings in this undo buffer directly. So that when you are editing something, you will write not in your main buffer, but in this undo buffer, and rendering will render: the part before, part in undo buffer, the part after.

modify the buffer itself only after you are finished with typing.

naaaah, fix it only if it will lag without it

but anyway, how will i make this undo buffer?

bool last_operation_was_addition
int last_position

I will ignore time completely, will only use those two. If last position doesn't match, then it's a new text, so a new undo entry.

void* prev_undo
void* next_undo
void* split
bool is_addition
int length
char* string

yeah, if something was deleted, copy it into undo buffer as well

My concern though, you know that you can delete in both directions? If you press "backspace", it will delete backward, and if you press delete, it will delete forward.

Solution: instead of using bool last_operation_was_addition, have 3 states: last_was_addition, last_was_backspace, last_was_delete. Simple, right?

Um, I think I'll have to do this "the part before, part in undo buffer, the part after" rendering thing after all. When I'll press a backspace, I need to copy the thing I deleted into an undo history, and I'll have to copy this string backwards. Imagine that I want to delete the word "backspace" by pressing "backspace" 9 times. I'll have to copy "e" somewhere, then I'll have to move this "e" to the right " e", and then add "c" "ce". Then move everything again " ce", and then add "a", "ace". Etc. I don't want that.

---
you know what I'll do? I'll fill all values from the code first, manually. When I'll check if ctrl-z ctrl-shift-z works.

---
Code:
struct undo_node {
        void* next;
        void* prev;
        void* split;
        int last_operation;
        int length;
};

//enum last_operation_state { 
//      last_was_addition , 
//      last_was_backspace, 
//      last_was_delete
//};

//enum last_operation_state last_operation;
//int last_position;
// don't need those, I'll have a link to "undo_current" instead
void* undo_root; //probably don't need this, but, why not
void* undo_current;
void* undo_free; //where the next undo_node will be stored
bool undo_committed = true; //if false, when use undo_current during rendering. If true, when it's already written in the buffer.    


Code:
        undo_root = memget();
        undo_current = undo_root;
        memget_guard("undo_current = undo_root;");

        {
                int* prev = (int*)undo_root;
                *prev = 0;
                int* next = (int*)undo_root + 1;
                *next = 0;
                struct undo_node* node = (struct undo_node*)((int*)undo_root + 2);
                ZeroMemory(node, sizeof(node));
        }    


Code:
        //TEXTEDITOR2
        //draw onscreen text (take 2, lol)
        //THIS IS THE TEXT EDITOR    


Code:
if (wParam == VK_BACK) {    
Post 02 Feb 2019, 09:31
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Got to the ending of Princess Maker 2, she became a pretty skilled painter that lacks imagination, but still got enough money from drawing portraits of nobles. "You was an passibly good father".

Me? "Passibly good"???

Loaded.

Sold +50 paining skill brush.

She became a f*cking general instead! And a good one, with both strength and intelligence! "You was a good father". That's better.

So, no army of demons in sight... Not sure why I concentrated on fighting then...
Post 02 Feb 2019, 20:24
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
A demon appears.
>fight
"You think you can beat a demon?"
>sword
Demon escaped.

...
...
...
well, he's correct, I can't beat him if he just keeps running away.
Post 02 Feb 2019, 20:26
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
aaaaand a few screenshots


Description:
Filesize: 142.79 KB
Viewed: 1800 Time(s)

Natasha Dripsikova.png


Description:
Filesize: 119.94 KB
Viewed: 1800 Time(s)

giant_scorpion_pm2.png


Post 02 Feb 2019, 20:29
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
downloaded the entire library of pc98 games

can't play them right now, don't remember where i put my chiitrans, newer versions are shit for some reason. I don't need machine translation, I only need instant dictionary popup. Learning all grammar is easy, learning the entire dictionary is very hard.

---
v=x5ygAlReZfI
Blue Stahli - Shotgun Senorita [Zardonic Remix] (HD)
this puts me in the mood, almost

and this
Dawnbreaker - Metrik ~ Forza Horizon 4 HR Radio [1 Hour Music Extended]-dNJh7aF1AKw.m4a
Post 03 Feb 2019, 13:25
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
added this piece of ugly

Code:
                        if (wait_for_commit) {
                                if (in_commit == false) {
                                        if (cur_osd == commit_start) {
                                                cur_osd_backup = cur_osd;
                                                cur_osd = (char*)(undo_current + 1);
                                                commit_length--;
                                                in_commit = true;
                                        }
                                }
                                else {
                                        if (commit_length == 0) {
                                                cur_osd = cur_osd_backup;
                                                wait_for_commit = false;
                                        }
                                        else {
                                                commit_length--;
                                        }
                                }
                        }    


ah, so want to try c++ iterators. Sucks that everything in c++ comes at a price though.

---
ugh, how to... understand if WM_CHAR came with ctrl pressed or not...

if (HIBYTE(VkKeyScan((TCHAR)wParam)) & 2) {

doesn't work for ctrl-c for example. Works for ctrl-z, but not for ctrl-c.

http://www.ngedit.com/a_wm_keydown_wm_char.html

https://blog.keyman.com/2008/06/robust-key-mess/

aah, later, don't leave undo in halffinished state

---
me? not getting distracted?

v=aB1psgIysBM
Cats and Dogs - Awesome Funny Animals (2018)

v=aT_ZcUC_W6k
Horrific animal attacks 2016 (GRAPHIC SCENES)

---
neir automata is very relaxing, strangely. Any game where you can stop and fish must be.

---
https://ecchi.iwara.tv/videos/qggvntb1gurymbv0
【R-18】欲求不満なmikuさんのMad Lovers

the gold. Good porn isn't just sexy, it's also highly entertaining. Good music, good animation, good model, good facial expressions, and somehow everything on the screen is oddly badass. How can porn be badass? How? Well, saying that badass people don't fuck is stupid, and saying people can't look confident while fucking is... understandable, but wrong.
Post 03 Feb 2019, 14:16
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1420
vivik wrote:
ugh, how to... understand if WM_CHAR came with ctrl pressed or not...
Use GetKeyState.
Post 04 Feb 2019, 00:29
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
I realized (after some sleep) that I shouldn't use WM_CHAR for keyboard shortcuts, because I'll get a different key for a different keyboard layout. I should use WM_KEYDOWN for keys, and WM_CHAR for text.

Also I realized that I can use WM_KEYDOWN WM_KEYUP to keep track of which control key is pressed, just need extra variables. I probably should check for WM_SETFOCUS WM_KILLFOCUS as well, want to know how window will react if I click outside the window with ctrl still pressed (or click in with ctrl pressed). https://docs.microsoft.com/en-us/windows/desktop/inputdev/about-keyboard-input

I planned to use scancodes for key input (example https://stackoverflow.com/questions/7311252/identify-key-uniquely-from-wm-keydown-message ), but let's keep things more universal and use virtual key codes.

Is it possible to get into a situation when during WM_CHAR or WM_KEYDOWN the ctrl is pressed, but during GetKeyState it's already released? You need to have really fast fingers for that, so, safe to ignore either way.

I'm pretty sure that windows explorer uses GetKeyState. Because I tried to send a keystroke to it through AutoHotKey, but got problems with ctrl.
Post 04 Feb 2019, 13:19
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 532
Location: Belarus
GetKeyState() reports the state of the keyboard at the moment the message being processed has been generated. To get current keyboard state no matter how late its processing occurs use GetAsyncKeyState().
Post 04 Feb 2019, 13:38
View user's profile Send private message Visit poster's website Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
14:23, 5 hours of walking the net aimlessly later.

v=UHyYuVQVBCM
Love Love *SNAP* (Magical Witch Punie-chan AMV)

v=ij4xzur16qg
Dai Mahou Touge episode 1a
2007
Post 05 Feb 2019, 10:24
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
found those two by searching "hitler rumia"

Upload Error: Could not upload Attachment to ./files/eanbdgb_937.jpg.
Filetype mismatch: expected png but jpg given.

oh, how nice/smart.


Description:
Filesize: 15.67 KB
Viewed: 1699 Time(s)

0qLvDJT8_400x400.jpg


Description:
Filesize: 45.8 KB
Viewed: 1700 Time(s)

EaNbdgb.jpg


Post 05 Feb 2019, 10:30
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
v=azEvfD4C6ow
Bagger 288!
I like the fact that the first boss in NieR:Automata is pretty much this. Except mecha.

Mechas are silly when they are too human. You can't just make a human, and make it 200 times bigger, no bone is strong enough to hold this together. Hey, maybe that's the point. Eh, dunno.

I'd post one video here, but don't know how to search for it. The black-white homebrew mecha animation, where mecha had a more tank-like movement, but still very mobile. Maybe I posted it here already? I don't remember.

---
v=9CNb6P-vcdM
Blue Water - Nadia: The Secret Of Blue Water Opening [Full]
look at that shading on that leg! Daym.

btw, i watched it. Quite a trainwreck at times, yet on other times best of the best.

---
do you know what the only piece of entertainment I actually payed for in the last 10-15 years was internet and electricity?

well, this pc sorta counts as well.

I'm paying for it in time mostly, tbh.

---
[Vinesauce] Joel - Horrible Phone Java Games-oXjZ4Cw8jtI.mp4
question one, why he's so retarded?
question two, why nobody else makes videos of java games?

now I know how to google those, just "java games".

---
v=mNJI7TxUkw0
i remember this illustration. Two artists made a crossover, for no other reason than that their nicknames were so simular. One of them made nekopara later. He sure got far.

I liked touhou kenchinroku a bit better (than nekopara), I prefer comedy over drama and sentimentality. Plus art served the story, unlike how in nekopara: story served the art, story is an afterthought for the cool shit an artist could draw.

On the other hand, nekopara got animated hcg. ... Nah, koakuma was hotter anyway.

---
v=8SqS93iAPG0
love of magical chimes slow
huh, didn't expect a slowed down version to sound this good. This song played right before the final boss, so compozer upped the tempo, probably a bit too much.

---
v=LLAy4GRqYL0
EastNewSound un owen was her slow
offvocal, huh
kinda boring, but why not

---
j^p^n - bloom. []
v=KM1RpI2S97o
with 100% ~less~ anime tiddy

https://drive.google.com/file/d/1hPiqsEYj1oJrFLc8-RxJqT1-ceDewEpQ/view?usp=sharing
with 100% ~MORE~ anime tiddy

must protec tiddy at all cost

it's a mediocre evangelion amv

it's really hard to make a evangelion amv that isn't visually impressive, visuals in general are really good. I just didn't like the music in this one.

---
リグルイ
a little fanwork of surprising proportions. It took me like 6 years to read, when I started it took me like 3 hours to read the first character, because he was written in an unfamiliar fassion, differently from the way webbrowsers draw it. My favorite thing about it is that I had no idea what it was going to be about, like 3-4 times I made a guess about a genre, and I was wrong. I'm probably the only one in my entire country who have read that. And it's sfw, would you believe that.

maybe i'll translate it one day. Doubt that though. Will you pay me for that?

---
step 1: write something stupid
step 2: try to understand what you just did
i love seeing bugs when I code, it's like it lives independently from me, like it's alive on its own.

most likely a bad sign.

---
v=ABwqPZ5bI9Y
Lucky Star OST - Bubbu Bubbu Budane, Lucky Star (Extended Version)
perfect working music (considering how shit i am)

---
v=ji9ShhqXNDI
_ensnare_ - Inevitable Sound Shower

v=ED6CuCcvZWg
messing with sunvox - tripflag

---
proper way to do word wrap:
before drawing the next word, see if it fits on screen (see for next space, newline, tab, whatever)

lazy way to do word wrap:
Code:
                        if (where_x >= 600.0f && c == ' ' || where_x >= 1000.0f) {
                                where_x = 0.0f;
                                where_y += 16.0f;
                        }    


ugh, will need to rewrite this anyway when making cursor movement... Down the line in a paragraph. Right now it just skips the entire paragraph... So I should keep newlines newlines_len newlines_len_used after all...

nay, it's easy and fast, just use characters instead of pixels and repeat all the \n \t ' ' logic. Renderer and navigation will have a very simular logic, but whatever, don't care.

Probably should keep one bit out of 32 to differentiate between real newlines and wordwrap newlines.

Go to the left, find \n, add it into newlines. From that \n, go to the right, count how many characters in the string there are, how many characters in the word there are, and add wordwrap newlines. When adding wordwrap newlines, shift everything to the left int by int, and then add the newest wordwrap newline to the most right position. When going left or right, check for //SNIPPETS if (((intptr_t)cur & 0xFF) == 0) if (((intptr_t)cur & 0xFF) == 0xFC)

---
tomorrow:
you made ctrl-z ctrl-shift-z, but they only change undo_committed
make a proper history navigation, modify the actual buffer in both directions
when redoing, follow next, then every split, stop on next==0
when undoing, follow back, stop on back==0
when typing something new when in the middle of undo chain, add new undo node, previous_node->split = current_node; current_node->prev = previous_node->prev;

after that, make DEL and BACKSPACE. Copy deleted strings into undo buffer, set add_or_del and direction

NOT NOW
navigating undo history properly would require to store where to turn on splits. Use a ring of integers, one integer per split, this will indicate where I am currently. 0 means not following split, 1 means following 1 split, etc. 0x100 should be enough.

---
youtube likes to hide my replies, huh

whenever i type something that is too long, it hides my post from everyone but me. Ugh, I feel so isolated.

---
can't force myself to work
i shouldn't even call this "work", who cares about a text editor?
something will click eventually

---
sm34559906
暖暖暖暖天使
I can do it! It's just a text editor, what's so hard about it?
you can do it, don't give up!

--
https://www.nicovideo.jp/watch/sm34569585
ゲーム機の性能の限界に挑戦・超越したソフトまとめ (α版)

v=_14_kTNMD2s
Game Boy Advance Longplay [018] Iridion 3D

watch?v=YtJJbaBCcDI&list=PLM4Ke1f2IhooyflMfnQqLARRLxIfxGWZD
Iridion 3D music - Stage 1

v=yPTKMKuW_s4
Iridion 3D - Diposal Tunnel
7GamerMinutes

---
hqcQqmOCzQE
「おちゃめ機能」FUKKIRETA.nsf
>.75 speed is actually p catchy
yeah, more romantic somehow
Post 05 Feb 2019, 11:17
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Hell yeah, undo-redo works. At least it looks like it works, need to test it later properly.

Code:
void undo() {
        if (undo_committed == false) {
                //simple, just change the view
                undo_committed = true;

                undo_current = undo_current->prev;

                g_display.need_redraw_not = 0;
        }
        else {
                if (undo_current->prev == 0) {
                        //already on oldest
                }
                else {
                        //the juice
                        //just shrink it



                        int length = undo_current->length;
                        
                        char* cursor_last = textfilebuf + textfilesize - 1;
                        char* cursor_from = textfilebuf + undo_current->offset + length;
                        char* cursor_to = textfilebuf + undo_current->offset; // + cursor - length
                        while (cursor_from < cursor_last) {
                                *cursor_to++ = *cursor_from++;
                        }

                        cursor = undo_current->offset;

                        undo_current = undo_current->prev;

                        g_display.need_redraw_not = 0;

                }
                
        }
}


void undo_redo() {
        if (undo_current->next == 0) {
                if (undo_committed == false) {
                        undo_committed = true;
                        g_display.need_redraw_not = 0;
                }

        }
        else {
                //the juice
                if (undo_current->split) {
                        do {
                                undo_current = undo_current->split;
                        } while (undo_current->split);
                }
                else {
                        if (undo_current->next) {
                                undo_current = undo_current->next;
                        }
                        else {
                                return;
                        }
                }



                g_display.need_redraw_not = 0;

                cursor = undo_current->offset;

                int length = undo_current->length;

                char* c = textfilebuf + textfilesize;
                char* cursor_last = textfilebuf + cursor + length - 1;
                for (; c != cursor_last; c--) {
                        *c = *(c - length);
                }


                char* cursor_from = (char*)(undo_current + 1);
                char* cursor_to = textfilebuf + cursor; // + cursor - length
                for (int i = 0; i != length; i++) {
                        *cursor_to++ = *cursor_from++;
                }

                cursor = undo_current->offset + length;


        }
        

}


void undo_create() {

        if (undo_current->next == 0) {
                undo_current = (struct undo_node*)((char*)undo_last + sizeof(struct undo_node) + undo_last->length);
                ZeroMemory(undo_current, sizeof(undo_current));
                undo_last->next = undo_current;
                undo_current->prev = undo_last;
                undo_last = undo_current;


        }
        else {
                //use ->split
                struct undo_node* undo_prev = undo_current;
                undo_current = (struct undo_node*)((char*)undo_last + sizeof(struct undo_node) + undo_last->length);
                ZeroMemory(undo_current, sizeof(undo_current));

                undo_prev->split = undo_current;
                undo_current->prev = undo_prev;
                undo_last = undo_current;

        }
}

void undo_commit() {
        if (undo_committed == false) {
                undo_committed = true;
                //different commit depending on if this is an addition or a deletion
                //right now only addition
                int length = undo_current->length;

                char* c = textfilebuf + textfilesize;
                char* cursor_last = textfilebuf + cursor + length - 1;
                for (; c != cursor_last; c--) {
                        *c = *(c - length);
                }
                

                char* cursor_from = (char*)(undo_current+1);
                char* cursor_to = textfilebuf + cursor; // + cursor - length
                for (int i = 0; i != length; i++) {
                        *cursor_to++ = *cursor_from++;
                }

                //*cursor_offset = wParam;

                cursor += length;

                //and now, create next commit as well


        }
}    


Now make backspace and del buttons.

VK_BACK VK_DELETE


Last edited by vivik on 08 Feb 2019, 07:42; edited 1 time in total
Post 08 Feb 2019, 07:09
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
RxkezvGwI20
Hokuto No Ken - You wa Shock full version

>My girlfriend hears this, now she is my boyfriend.

>my wife listened to this, I'm his wife now

>Had sex in tune to this, she's already dead.

all of testosterone, all of it

just liked comments, that's all. Never watched the show. I rarely watch anything.

---
Ro7RQtLUdGw
_ensnare_ - Top Five Control

---
somebody once said that pascal is a toy compared to c because it doesn't have type casting. Now I understand why type casting is important. With typecasting I can do with memory literally everything. It is like temporarily disabling c type checking.

---
fVGzxljiNKg
Jealous Imouto Compilation

>Huh. A list completely dedicated to trash...
>4:08 Except you. You're precious.

---
v_ENy0iAJPs
【終物語】八九寺さん怒りのパンチ

少女が好きで幼女が好きで童女が好きでスカートの裏地が好きで女子の腰つきが好きで大きなおっぱいが好きで雑に扱われるのが好きで大きな妹が好きで小さな妹が好きで熟女が好きで上半身裸が好きでブルマが好きでスクール水着が好きで委員長が好きでボクっ子が好きでネコ耳が好きでスポーツ少女が好きで!!

生きるのが大好きな人だったじゃないですかっ!

---
programming feels like a heavy lifting or a long distance running to me. I need to keep a lot of things in my head for a long time. I start remembering things when I start to work, and then I forget things when I'm done. And this period of remembering makes me feel like I'm holding something heavy, and I want to put it down already.

I usually stop programming when I'm (1) tired, (2) just finished something and may relax/forget for a bit, (3) don't have enough time left to finish anything anyway.

Wonder if I'm just stupid/lazy or it's a usual process.

Sometimes thinking happens effortlessly, this is when ideas come in. I write them down for later.

Sleep really helps. Being confused for hours before sleep and solving it in 5 minutes after you slept is quite common.

I'm programming disturbingly slowly. Maybe I shouldn't be a programmer?

I'm getting distracted alot. I'm hungry for something. Opening youtube takes me two seconds (ctrl-t y enter), often I do it without realizing what I've done. Not sure if I should just feed this hunger, ignore it and just willpower anyway, or something else. Things I'm trying to ignore is the life itself (yeah, youtube is life), ignoring life is a suicide, nothing matters more. On the other hand, the more I'm feeding, the bigger the next dose should be, and the longer the pause between food, the better it feels. It sounds like I'm talking about porn or drugs right now, but it applies to everything, food, bed.

---
5k8PaUMQaAc
Warcraft 3 - 1 vs 11 Insane computers (Human on Ice Crown)

it's 2 hours. I watched it. No regrets.

heroes 3 wayfarer letsplay, around 7 videos, 8 hours each. I watched 4 of them. No regrets. (Kept falling asleep on the 4th one, this is why it took so long, almost half a year can't finish watching it)

video games and drawings are the only areas where I can see people be really good at what they are doing. There are also sports, but, (1) many artificial limitations and (2) every match/competition is exactly the same, too boring. Politics are too slowpaced, and every news source is not very trustworthy and biased. Movies are fiction that you can't get real world knowledge from. Tourism, I can just watch it on screen to the same effect, I don't need to be there to see them.

Nobody wants to stream themself working?
Post 08 Feb 2019, 07:40
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Made VK_BACK, now do VK_DELETE

Code:
void undo() {
        if (undo_committed == false) {
                //simple, just change the view
                undo_committed = true;

                undo_current = undo_current->prev;

                g_display.need_redraw_not = 0;
        }
        else {
                if (undo_current->prev == 0) {
                        //already on oldest
                }
                else {

                        if (undo_current->add_or_del == false) {
                                //addition

                                //the juice
                                //just shrink it

                                int length = undo_current->length;

                                char* cursor_to = textfilebuf + undo_current->offset;
                                char* cursor_from = textfilebuf + undo_current->offset + length;
                                char* cursor_last = textfilebuf + textfilesize;
                                while (cursor_from < cursor_last) {
                                        *cursor_to++ = *cursor_from++;
                                }

                                cursor = undo_current->offset;
                                textfilesize -= undo_current->length;

                                undo_current = undo_current->prev;

                                g_display.need_redraw_not = 0;

                        }
                        else {
                                //deletion

                                //expand space for your undo text
                                //then copy undo text on place

                                int length = undo_current->length;

                                {
                                        char* cursor_last = textfilebuf + undo_current->offset - length - 1;
                                        char* cursor_from = textfilebuf + textfilesize;
                                        char* cursor_to = textfilebuf + textfilesize + length;
                                        while (cursor_from != cursor_last) {
                                                *cursor_to-- = *cursor_from--;
                                        }
                                }

                                {
                                        char* cursor_from = (char*)(undo_current + 1);
                                        char* cursor_to = textfilebuf + undo_current->offset - length;
                                        for (int i = 0; i < length; i++) {
                                                *cursor_to++ = *cursor_from++;
                                        }
                                }

                                cursor = undo_current->offset;
                                textfilesize += length;

                                undo_current = undo_current->prev;

                                g_display.need_redraw_not = 0;

                        }

                }
                
        }
}


void undo_redo() {

        if (undo_current->next == 0) {
                return;
        }

        //don't really need to bother with undo_committed in redo
        //the only purpose of undo_committed is that you don't move the entire file char by char as you type
        //that commits are happen in packs
        //when you redo, this is exactly what happens

        //yet, what will happen if I try to redo while it's not committed yet?
        //undo_current->next == 0 happens
        
        //the juice
        if (undo_current->split) {
                do {
                        undo_current = undo_current->split;
                } while (undo_current->split);
        }
        else {
                if (undo_current->next) {
                        undo_current = undo_current->next;
                }
                else {
                        return;
                }
        }



        g_display.need_redraw_not = 0;

        cursor = undo_current->offset;

        if (undo_current->add_or_del == false) {
                //addition

                int length = undo_current->length;

                char* c = textfilebuf + textfilesize;
                char* cursor_last = textfilebuf + cursor + length - 1;
                for (; c != cursor_last; c--) {
                        *c = *(c - length);
                }


                char* cursor_from = (char*)(undo_current + 1);
                char* cursor_to = textfilebuf + cursor; // + cursor - length
                for (int i = 0; i != length; i++) {
                        *cursor_to++ = *cursor_from++;
                }

                cursor = undo_current->offset + length;
                textfilesize += undo_current->length;

        }
        else {
                //deletion

                //just shift characters to the left
                //hm, let's arrange those 3 in the order from smaller to bigger
                char* cursor_to = textfilebuf + cursor - undo_current->length; // + cursor - length
                char* cursor_from = textfilebuf + cursor;
                char* cursor_end = textfilebuf + textfilesize;
                while (cursor_from != cursor_end) {
                        *cursor_to++ = *cursor_from++;
                }

                cursor -= undo_current->length;
                textfilesize -= undo_current->length;
        }


}


void undo_commit() {
        if (undo_committed == false) {
                undo_committed = true;
                //different commit depending on if this is an addition or a deletion
                //right now only addition
                if (undo_current->add_or_del == false) {
                        //addition
                        int length = undo_current->length;

                        {
                                char* cursor_from = textfilebuf + textfilesize;
                                char* cursor_to = textfilebuf + textfilesize + length;
                                char* cursor_last = textfilebuf + cursor + length - 1;
                                for (; cursor_to != cursor_last; ) {
                                        *cursor_to-- = *cursor_from--;
                                }
                        }

                        {
                                char* cursor_from = (char*)(undo_current + 1);
                                char* cursor_to = textfilebuf + cursor; // + cursor - length
                                for (int i = 0; i != length; i++) {
                                        *cursor_to++ = *cursor_from++;
                                }
                        }

                        //*cursor_offset = wParam;

                        cursor += length;
                        textfilesize += length;
                }
                else {
                        //deletion
                        //just shift characters to the left
                        //hm, let's arrange those 3 in the order from smaller to bigger
                        char* cursor_to = textfilebuf + cursor - undo_current->length; // + cursor - length
                        char* cursor_from = textfilebuf + cursor;
                        char* cursor_end = textfilebuf + textfilesize;
                        while (cursor_from != cursor_end) {
                                *cursor_to++ = *cursor_from++;
                        }

                        cursor -= undo_current->length;
                        textfilesize -= undo_current->length;
                }

        }
}

void undo_create() {

        if (undo_current->next == 0) {
                undo_current = (struct undo_node*)((char*)undo_last + sizeof(struct undo_node) + undo_last->length);
                ZeroMemory(undo_current, sizeof(undo_current));
                undo_last->next = undo_current;
                undo_current->prev = undo_last;
                undo_last = undo_current;


        }
        else {
                //use ->split
                struct undo_node* undo_prev = undo_current;
                undo_current = (struct undo_node*)((char*)undo_last + sizeof(struct undo_node) + undo_last->length);
                ZeroMemory(undo_current, sizeof(undo_current));

                undo_prev->split = undo_current;
                undo_current->prev = undo_prev;
                undo_last = undo_current;

        }
}    


actually, do copypaste first. Or navigation to the next line...
not sure.

---
just a bit more, and this will be actually useful
Post 09 Feb 2019, 21:24
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Opening my amv folder:

Clannad/JazzsVids_-_Vacant Heart.mp4
jmJ2y2yYzXQ
AMV - Vacant Heart - Bestamvsofalltime Anime MV ♫

a bit spoilerific, I guess. Eh, not like I ever watch anything that I wasn't spoiled about. The only exception is screamers, but comments are usually there to spoil me anyway.

music:
32udqal_lyQ
Crystal Castles - Not In Love ft. Robert Smith of The Cure

no lyrics/off vocal/instrumental/karaoke
1KKVvYn1Bs8
Not In Love // KARAOKE // Crystal Castles
(voice stands in the way of that godly sound)
(ugh, a bit of voice is still there...)

http://amvnews.ru/index.php?go=Files&in=view&id=6006
https://www.animemusicvideos.org/members/members_videoinfo.php?v=195948

---
tv is so good, life becomes hopelessly boring

wish I could move around at a fast enough speed, like 10 times my usual speed. Like, "quake speedrun" speed.

---
ahaha, try playing Soi9tIq1_ZM and 1KKVvYn1Bs8 at the same time! They go surprisingly well together.

aaaah, my ears are bleeding

do i honestly prefer somebody yelling into my ears to that vocal? honestly?

let's add this ICjD3f-8SXE

and another tab of Soi9tIq1_ZM , twice

i'm dying, help

---
wIpYy1wvzQk
NOT IN COCK
Post 10 Feb 2019, 10:18
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
Code:
void undo() {
        if (undo_committed == false) {
                //simple, just change the view
                undo_committed = true;

                undo_current = undo_current->prev;

                g_display.need_redraw_not = 0;
        }
        else {
                if (undo_current->prev == 0) {
                        //already on oldest
                }
                else {

                        if (undo_current->add_or_del == false) {
                                //addition

                                //the juice
                                //just shrink it

                                int length = undo_current->length;

                                char* cursor_to = textfilebuf + undo_current->offset;
                                char* cursor_from = textfilebuf + undo_current->offset + length;
                                char* cursor_last = textfilebuf + textfilesize;
                                while (cursor_from < cursor_last) {
                                        *cursor_to++ = *cursor_from++;
                                }

                                cursor = undo_current->offset;
                                textfilesize -= undo_current->length;

                                undo_current = undo_current->prev;

                                g_display.need_redraw_not = 0;

                        }
                        else {
                                //deletion

                                //expand space for your undo text
                                //then copy undo text on place

                                int length = undo_current->length;

                                {
                                        char* cursor_last = textfilebuf + undo_current->offset - length - 1;
                                        char* cursor_from = textfilebuf + textfilesize;
                                        char* cursor_to = textfilebuf + textfilesize + length;
                                        while (cursor_from != cursor_last) {
                                                *cursor_to-- = *cursor_from--;
                                        }
                                }

                                {
                                        char* cursor_from = (char*)(undo_current + 1);
                                        char* cursor_to = textfilebuf + undo_current->offset - length;
                                        for (int i = 0; i < length; i++) {
                                                *cursor_to++ = *cursor_from++;
                                        }
                                }

                                cursor = undo_current->offset;
                                textfilesize += length;

                                undo_current = undo_current->prev;

                                g_display.need_redraw_not = 0;

                        }

                }
                
        }
}


void undo_redo() {

        if (undo_current->next == 0) {
                return;
        }

        //don't really need to bother with undo_committed in redo
        //the only purpose of undo_committed is that you don't move the entire file char by char as you type
        //that commits are happen in packs
        //when you redo, this is exactly what happens

        //yet, what will happen if I try to redo while it's not committed yet?
        //undo_current->next == 0 happens
        
        //the juice
        if (undo_current->split) {
                do {
                        undo_current = undo_current->split;
                } while (undo_current->split);
        }
        else {
                if (undo_current->next) {
                        undo_current = undo_current->next;
                }
                else {
                        return;
                }
        }



        g_display.need_redraw_not = 0;

        cursor = undo_current->offset;

        if (undo_current->add_or_del == false) {
                //addition

                int length = undo_current->length;

                char* c = textfilebuf + textfilesize;
                char* cursor_last = textfilebuf + cursor + length - 1;
                for (; c != cursor_last; c--) {
                        *c = *(c - length);
                }


                char* cursor_from = (char*)(undo_current + 1);
                char* cursor_to = textfilebuf + cursor; // + cursor - length
                for (int i = 0; i != length; i++) {
                        *cursor_to++ = *cursor_from++;
                }

                cursor = undo_current->offset + length;
                textfilesize += undo_current->length;

        }
        else {
                //deletion

                //just shift characters to the left
                //hm, let's arrange those 3 in the order from smaller to bigger
                char* cursor_to = textfilebuf + cursor - undo_current->length; // + cursor - length
                char* cursor_from = textfilebuf + cursor;
                char* cursor_end = textfilebuf + textfilesize;
                while (cursor_from != cursor_end) {
                        *cursor_to++ = *cursor_from++;
                }

                cursor -= undo_current->length;
                textfilesize -= undo_current->length;
        }


}


void undo_commit() {
        if (undo_committed == false) {
                undo_committed = true;
                //different commit depending on if this is an addition or a deletion
                //right now only addition
                if (undo_current->add_or_del == false) {
                        //addition
                        int length = undo_current->length;

                        {
                                char* cursor_from = textfilebuf + textfilesize;
                                char* cursor_to = textfilebuf + textfilesize + length;
                                char* cursor_last = textfilebuf + cursor + length - 1;
                                for (; cursor_to != cursor_last; ) {
                                        *cursor_to-- = *cursor_from--;
                                }
                        }

                        {
                                char* cursor_from = (char*)(undo_current + 1);
                                char* cursor_to = textfilebuf + cursor; // + cursor - length
                                for (int i = 0; i != length; i++) {
                                        *cursor_to++ = *cursor_from++;
                                }
                        }

                        //*cursor_offset = wParam;

                        cursor += length;
                        textfilesize += length;
                }
                else {
                        //deletion
                        //just shift characters to the left
                        //hm, let's arrange those 3 in the order from smaller to bigger
                        char* cursor_to = textfilebuf + cursor - undo_current->length; // + cursor - length
                        char* cursor_from = textfilebuf + cursor;
                        char* cursor_end = textfilebuf + textfilesize;
                        while (cursor_from != cursor_end) {
                                *cursor_to++ = *cursor_from++;
                        }

                        cursor -= undo_current->length;
                        textfilesize -= undo_current->length;
                }

        }
}

void undo_create() {

        if (undo_current->next == 0) {
                undo_current = (struct undo_node*)((char*)undo_last + sizeof(struct undo_node) + undo_last->length);
                ZeroMemory(undo_current, sizeof(undo_current));
                undo_last->next = undo_current;
                undo_current->prev = undo_last;
                undo_last = undo_current;


        }
        else {
                //use ->split
                struct undo_node* undo_prev = undo_current;
                undo_current = (struct undo_node*)((char*)undo_last + sizeof(struct undo_node) + undo_last->length);
                ZeroMemory(undo_current, sizeof(undo_current));

                undo_prev->split = undo_current;
                undo_current->prev = undo_prev;
                undo_last = undo_current;

        }
}

void text_insert_char(int insert) {
        char* c;
        if (undo_committed == true || undo_committed == false && undo_current->add_or_del == true) {
                //first time
                undo_commit();
                undo_create();
                c = (char*)(undo_current + 1);
                undo_current->offset = cursor;
                undo_current->length = 1;
                //cursor++;
        }
        else {
                c = (char*)(undo_current + 1) + undo_current->length;
                undo_current->length++;
        }
        if (insert & 0xFF00) {
                //not ascii
                undo_current->length++;
        }
        else {
                *c = insert;
        }

        undo_committed = false;

        g_display.need_redraw_not = 0;
}

void text_backspace() {
        char* c;
        if (undo_committed == true || undo_committed == false && undo_current->add_or_del == false) {
                undo_commit();
                undo_create();
                undo_current->offset = cursor;
                undo_current->length = 1;
                undo_current->add_or_del = true;
        }
        else {
                c = (char*)(undo_current + 1) + undo_current->length;
                undo_current->length++;
        }

        //need to copy deleted chars for later undo
        //first just shift all characters in commit to the right, one (or multiple for utf8) byte to the right

        int length = undo_current->length;

        char* cursor_from = (char*)(undo_current + 1) + undo_current->length - 2; //it works, don't ask why
        char* cursor_to = cursor_from + 1; // + cursor - length
        char* cursor_end = (char*)(undo_current + 1);
        while (cursor_to > cursor_end) {
                *cursor_to-- = *cursor_from--;
        }

        cursor_from = textfilebuf + cursor - length;
        //then just copy the current character
        *cursor_to = *cursor_from;

        //not now, just see if it works

        undo_committed = false;

        g_display.need_redraw_not = 0;
}

void text_scroll_up() {
        
        char *cur_osd = textfilebuf + screen_start;
        cur_osd--;

        while (true) {
                cur_osd--;
                char c = *cur_osd;
                if (cur_osd <= textfilebuf) {
                        cur_osd = textfilebuf;
                        break;
                }
                if (c == '\n') {
                        cur_osd++;
                        break;
                }
        }

        screen_start = (int)(cur_osd - textfilebuf);


}

void text_scroll_down() {
        char *cur_osd = (char*)textfilebuf + screen_start;

        while (true) {
                char c = *cur_osd;
                cur_osd++;
                if (c == '\n') {
                        break;
                }
        }

        screen_start = (int)(cur_osd - textfilebuf);
}

void text_left() {
        undo_commit();
        cursor--;
        char* cursor_offset = textfilebuf + cursor;
        while ((*cursor_offset & 0xC0) == 0x80) {
                cursor_offset--;
                cursor--;
        }

        g_display.need_redraw_not = 0;
}

void text_right() {
        undo_commit();
        cursor++;
        char* cursor_offset = textfilebuf + cursor;
        while ((*cursor_offset & 0xC0) == 0x80) {
                cursor_offset++;
                cursor++;
        }

        g_display.need_redraw_not = 0;
}    
Post 13 Feb 2019, 16:50
View user's profile Send private message Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 669
No posts exist for this topic
Post 14 Feb 2019, 07:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16618
Location: In your JS exploiting you and your system
vivik wrote:
No posts exist for this topic
It will soon.
Post 14 Feb 2019, 09:48
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16618
Location: In your JS exploiting you and your system
revolution wrote:
vivik wrote:
No posts exist for this topic
It will soon.
It will soon.
Post 14 Feb 2019, 09:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... , 13, 14, 15  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.