Command Functions | Line Editor in C #2
Changing from a switch statement for commands to using separate command functions, called via a function pointer array. Also adding basic 'i' insert and 'c' change commands.
Errata: the cmd_functions array should be [256], not [128], as an unsigned char dereference can go outside the signed char range!
Fixed that issue and the function indentation after this was recorded.
There will be more memory issues I miss in the future, some can be caught from using sanitizers or valgrind, etc., or by using a better language :p
Playlist: • Line Editor (ed clone)
Git repo:
https://codeberg.org/queso_fuego/lined
https://github.com/queso-fuego/lined
Commit before this video:
git checkout c431818ae0b98ebad790c5f1b33f25c9131e8505
Commit after this video:
git checkout 5e9e5d9d2cac8619e41d4216d3fd3f7d90660d06
Links:
https://man.cat-v.org/unix-1st/1/ed
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ed.html
https://man.openbsd.org/ed.1
Join the Community Discord: https://discord.gg/yKm4T89QFn
Contact: https://queso_fuego.codeberg.page/contact.html
Support: https://queso_fuego.codeberg.page/support.html
Misc. notes:
I'm gonna say using the mouse for scrolling is akin to physically scrolling the paper output of a teletype, and mouse copy/paste would be physically cutting/combining/reading segments of paper tape or copying punch cards. So still not cheating (yet).
To fix extra indentation/whitespace issues with ed, you can do "a1,a2s:^\t\t::" where a1 and a2 are line addresses and \t is a literal tab character.
That would replace the first 2 tabs at the start of a line with nothing, removing them.
Thankfully, 's' allows non-backslash delimiters, which can make things a lot easier to read, depending on the regex and replacement.
00:00:00 only copy source file in make if changed
00:01:16 switch the switch to functions instead
00:20:35 add insert and change commands
00:36:42 up next & outro
Music credits:
In The End - HoliznaCC0
https://holiznacc0.bandcamp.com/track/in-the-end
#texteditor #cprogramming #edclone
Other Videos By Queso Fuego
Other Statistics
Counter-Strike: Source Statistics For Queso Fuego
Queso Fuego presently has 4,550 views for Counter-Strike: Source across 3 videos, with approximately 3 hours of Counter-Strike: Source video on his channel. This is less than 0.95% of the total video content that Queso Fuego has uploaded to YouTube.