diff options
author | Raymaekers Luca <luca@spacehb.net> | 2025-04-27 12:52:06 +0200 |
---|---|---|
committer | Raymaekers Luca <luca@spacehb.net> | 2025-04-27 13:05:34 +0200 |
commit | f87f7b4f0aaccc65d03ccee5bb11915ead6fb0e1 (patch) | |
tree | d54df0bfde3dbffa02b1f138af4f12456f261e54 /notes | |
parent | 0574f5a7c5159a2ae1d7d2182cec982509947db9 (diff) |
First pass at preparing for Github
Diffstat (limited to 'notes')
-rw-r--r-- | notes/archived.md | 31 | ||||
-rw-r--r-- | notes/chatty.md | 76 | ||||
-rw-r--r-- | notes/insert.md | 68 | ||||
-rw-r--r-- | notes/scroll.md | 63 |
4 files changed, 238 insertions, 0 deletions
diff --git a/notes/archived.md b/notes/archived.md new file mode 100644 index 0000000..62def2d --- /dev/null +++ b/notes/archived.md @@ -0,0 +1,31 @@ +## Client +- [x] prompt +- [x] sending message +- [x] bug: do not allow sending empty message +- [x] wrapping messages +- [x] bug: when sending message after diconnect (serverfd?) +- [x] Handle disconnection thiin a thread, the best way would be +- [x] Add limit_y to printf_wrap +- [x] id2string on clients +- [x] ctrl+z to suspend +- [x] bug: when reconnecting nrecv != -1 +- [x] bug: when disconnecting +- [x] use error type success to say that authentication succeeded +- [x] markup for messages +- [x] clipboard shortcut +- [x] tab as spaces support +- [x] fixed empty messages with markup characters + +## Server +- [x] import clients + +## Common +- [x] handle messages that are too large +- [x] refactor i&self into conn +- [x] logging +- [x] Req|Inf connection per client +- [x] connect/disconnect messages +- [x] bug: blocking after `Added pollfd`, after importing a client and then connecting with the + id/or without? After reconnection fails chatty blocks (remove sleep) +- [x] connect/disconnections messages +- [x] asserting, logging if fail / halt execution diff --git a/notes/chatty.md b/notes/chatty.md new file mode 100644 index 0000000..77a3886 --- /dev/null +++ b/notes/chatty.md @@ -0,0 +1,76 @@ +# Chatty +The idea is the following: +- tcp server that you can send messages to +- history upon connecting +- date of messages sent +- client for reading the messages and sending them at the same time +- rooms +- encryption +- authentication + +## client +- [ ] BUG: text is not appearing after typing +- [ ] BUG: when connecting two clients of the same account +- [ ] BUG: wrapping does not work and displays nothing if there is no screen space +- [ ] BUG: reconnect does not work when server does not know id +- [ ] TODO: Convert tabs to spaces +- [ ] BUG: when using lots of markup characters +- [ ] TODO: Newline support + - [ ] resizable box + +## server +- [ ] check that fds arena does not overflow + - free clients which disconnected and use free list to give them space +- [ ] check if when sending and the client is offline (due to connection loss) what happens +- [ ] timeout on recv? +- [ ] use threads to handle clients/ timeout when receiving because a client could theoretically + stall the entire server. +- [ ] do not crash on errors from clients + - implement error message? + - timeout on recv with setsockopt +- [ ] theoretically two clients can connect at the same time. The uni/bi connections should be + negotiated. + +## common +- [ ] use IP address / domain +- [ ] chat history +- [ ] rooms +- [ ] compression + +## Protocol +- see `protocol.h` for more info +- The null terminator must be sent with the string. +- The text can be arbitrary length + +### To Read +#### C Programming +- https://www.youtube.com/watch?v=wvtFGa6XJDU +- https://nullprogram.com/blog/2023/02/11/ +- https://nullprogram.com/blog/2023/02/13/ +- https://nullprogram.com/blog/2023/10/08/ +#### Encryption w/ Compression +- https://en.wikipedia.org/wiki/BREACH +- https://en.wikipedia.org/wiki/CRIME +- https://crypto.stackexchange.com/questions/2283/crypto-compression-algorithms +- openpgp https://www.rfc-editor.org/rfc/rfc4880 +- https://security.stackexchange.com/questions/19911/crime-how-to-beat-the-beast-successor +- https://blog.qualys.com/product-tech/2012/09/14/crime-information-leakage-attack-against-ssltls +- Algorithms: + *Symmetric* + - AESI + - Blowfish + - Twofish + - Rivest Cipher (RC4) + *Assymetric* + - Data Encryption Standard (DES) + - ECDSA + - RSA + - Diffie-Hellman + - PGP + _Hash_ + - Deflate + - Huffman Coding + - LZ77 + Other + - ChaCha20-Poly1305 + - AES(-GCM) diff --git a/notes/insert.md b/notes/insert.md new file mode 100644 index 0000000..cb00d1c --- /dev/null +++ b/notes/insert.md @@ -0,0 +1,68 @@ +# 1. InputBox + +InputBox(u32 BoxX, u32 BoxY, u32 BoxWidth, u32 BoxHeight, + wchar_t *Text, u32 TextLen, u32 TextIndex, + Bool Focused) + +TextIndex is where the edit cursor is in the text, so where the text should be displayed? + +It is most user friendly when the text moves as least as possible, so giving an offset will make it +scroll each time the user moves the cursor. No it should only move when the user moves the cursor +out of bounds. + + +There should be cursor logic and text logic + +# 2. Redraw text based on cursor + +```c +void +Redraw(u32 DrawnStart, u32 DrawnEnd) +{ + +} + +Box(BoxX, BoxY, Width, Height); +BoxedText(X+1, Y+1, Width-2, Height-2, + TextLen, Text); + +if (ev.key == TB_KEY_ARROW_LEFT) +{ + CursorX--; + TextIndex--; +} +else if (ev.key == TB_KEY_ARROW_RIGHT) +{ + CursorX++; + TextIndex++; +} +else if (ev.key == TB_KEY_ARROW_UP) +{ + // Scroll Up, Update TextIndex, Redraw +} +else if (ev.key == TB_KEY_ARROW_DOWN) +{ + // Scroll Down, Update TextIndex, Redraw +} +else if (ev.ch) +{ + Text[Textlen++] = ev.ch; + TextIndex++; + CursorX++; +} + +if (CursorX == BoxX + Width) +{ + // Scroll Down || Next Line (if empty) + // Update TextIndex, Redraw +} +else if (CursorX == BoxX) +{ + // Scroll up, Update TextIndex, Redraw +} +```` +It can be deterministic how we draw the text, and the cursor position is only needed to know where +to insert text. + +1. Do text insertion +2. Redrawing diff --git a/notes/scroll.md b/notes/scroll.md new file mode 100644 index 0000000..f36e774 --- /dev/null +++ b/notes/scroll.md @@ -0,0 +1,63 @@ +# The scrolling problem: +If the text is wrapped on whitespace this means that when we scroll up we do not go +backwards by text width. It is important to update the text correctly because we want +the complete text to always look the same so that when the user can see what they expect +to see (in this case the previous text). + +# 1. Find based on skipped characters +New position could be +`InputPos - (TextWidth - Skipped)` + +This means that the place where the wrapping is done must somehow return the number of +skipped characters. + +Or we can run the wrapping algorithm on the current line to check if wrapping would +have been done and how much characters it would have skipped. + +# 2. Wrapping as is: +Searching the text backwards for whitespace works good for an existsing text. But we +have a text that we append to a lot, so it might be more interesting to add wrapping +when adding characters. + +When we add a character at the end of the line and it is not a space *wrap*. + +Problem: What if we are in the middle of the text. +1. Check the last character +2. Is it a space + y) ignore + n) search backwards for space and wrap there + +Problem: How to print +Have the wrapping algorithms on adding a character and printing be the same, which +means that if we wrapped after printing a character we should print it correctly. + +# 3. Wrapping with special characters: +To create special characters (formatting, wrapping, etc.) and preserving unicode we can +implement special characters by making our text into a special linked list structure. + +> Example +```c +typedef enum { + NodeText = 0, + NodeBold, + NodeWrap +} node_type; + +typedef stuct { + node_type Type; + wchar_t *Text; + text_node *Prev; + text_node *Next; +} text_node; + +text_node First = { NodeText, L"Hello Foo!", 0, 0 }; +text_node Second = { NodeWrap, 0, &NodeText, 0 }; +First.Next = &Second; +``` +# Notes +- We should add a special (colored?) char to show the text is wrapped because that can + be hard to tell when spaces are same as empty. +- What if we end up on a wrapping char? +- Implement 2 for wrapping +- Implement 1 for cursor movement +- Implement 3 for formatting later and instead use text start and finish |