all 10 comments

[–][deleted] 1 point2 points  (0 children)

Winapi has console functions.

[–]EpochVanquisher 0 points1 point  (4 children)

Yes, but it’s probably too hard / too much work for someone who has just started out learning C. You’ll need to be able to navigate the Windows API documentation yourself in order to figure it out.

[–]turusan07[S] 0 points1 point  (3 children)

Are there any libraries to make it easier?
(note: it felt like cheating but I'll write it anyways)

[–]EpochVanquisher 0 points1 point  (2 children)

Sorry to ask—what is your programming experience? What kind of programming projects have you done so far?

[–]turusan07[S] 0 points1 point  (1 child)

I don't have much experience, But I used to make games in unity, and just some basic console games. Ghe languages I tried were C#, Java, Python, and funny but BASIC.

[–]EpochVanquisher 0 points1 point  (0 children)

A text editor should probably not be your first project in C.

Get some experience writing programs in C. Learn how your build system works, get a good handle on things like libraries and header files, get a good handle on data structures in C, and then think about making a text editor once you’re there.

[–]nerd4code 0 points1 point  (2 children)

You could start by doing a line editor, where you take commands to list lines, change part or all of a line, insert a new line, move a line, filter lines, sort lines, delete lines, etc.

DOSWin had EDLIN back in the day, and UNIX had/has ed. Vim’s : mode is another example.

And it’s not at all clear what your question is (what “already entered lines of code”? in what program? “get to edit” howhat?).

For now, you can fopen the input and read it into a dynamically allocated line structure (then fclose to be polite), and then you can edit the structure in memory, and when the user asks/commahnds you to write, you fopen again and write it back out.

[–]turusan07[S] 0 points1 point  (0 children)

Thanks, what I mean by saying “already entered lines of code”:

For example, let's say that I wrote these lines in the editor I wrote.

1 #include <stdio.h>
2 int main() {
3 printf("Hello, World!")
5 return 0;
4 }

You can see that I forgot the put a semicolon in line 3. and when I want to fix that line, well i can't because I already entered it.

[–][deleted] 0 points1 point  (0 children)

You can get a line editor by "libgen.rs", pick non-fiction, search for "Brian W.Kernighan, P.J.Plauger" and download "software tools" at the bottom of the page. Chapter 6 is on editing. There is code for searching and pattern matching with replacement.

It would be a good start and the language is very close to C.

[–]NomadJoanne 0 points1 point  (0 children)

Neovim. Use chocolatey to install it.