Skip to content

CLI text editor written in C, following 42's Norminette

License

Notifications You must be signed in to change notification settings

librity/ft_kilo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The 42-compliant Kilo Text editor

42 São Paulo License Code size in bytes Lines of code Top language Last commit

A simple terminal text editor compliant with 42's standards.


📜 Table of Contents

🧐 About

“Programs do one thing, do it well, and act on files.” Some bearded nerd in the 70's

CLI text editor written in C, following 42's Norminette. Inspired by:

📝 Notes

Compile and Run

Using make:

$ make && ./kilo
$ make clean
  1. Install
$ git clone https://github.com/42Paris/norminette.git ~/.norminette/
$ cd ~/.norminette/
$ bundle

$ echo 'alias norminette="~/.norminette/norminette.rb"' >> ~/.bash_profile
$ source ~/.bash_profile
  1. Run
$ norminette *.c **/*.c **/*.h

Quirks

/*
** This is a proper norminette comment
*/

int		main(void)
{
	int		variable_one;
	char	variable_two;

	variable_one = 42;
	return (0);
}

Makefile

  • $(CC) is a variable that make expands to cc by default.
  • -Wall stands for “all Warnings”, and gets the compiler to warn you when it sees code in your program that might not technically be wrong, but is considered bad or questionable usage of the C language, like using variables before initializing them.
  • -Wextra, -Werror and -pedantic turn on even more warnings. For each step in this tutorial, if your program compiles, it shouldn’t produce any warnings except for “unused variable” warnings in some cases. If you get any other warnings, check to make sure your code exactly matches the code in that step.
  • -std=c99 specifies the exact version of the C language standard we’re using, which is C99. C99 allows us to declare variables anywhere within a function, whereas ANSI C requires all variables to be declared at the top of a function or block.

Contains the definitions used by the terminal I/O interfaces.

  • IXON: input bitflag that enables XOFF and XON signal, Ctrl-S and Ctrl-Q respectively.

  • ICRNL: input bitflag that enables the terminal to interpret a carriage return as a new line.

  • BRKINT: input bitflag sends a SIGINT signal to the program whenever it reaches a break condition.

  • INPCK: input bitflag that enables parity checking.

  • ISTRIP: input bitflag that "strips" the 8th bit of each input byte, i.e., sets it to 0.

  • OPOST: output bitflag that enables post-processing of output, like \n into \r\n. When we disable it, the terminal emulator doesn't input a carriage return after every new line and the output "stairs down" the terminal.

  • CS8: bit mask that sets the character size (CS) to 8 bits per byte.

  • ECHO: local bitflag that causes each key you type to be printed to the terminal. Disabling it no longer prints everything we type on the terminal.

  • ICANON: local bitflag that enables canonical mode, i.e., reads input line-by-line. Disabling it allows us to read input byte-by-byte.

  • ISIG: local bitflag that enables SIGINT and SIGTSTP signal, Ctrl-C and Ctrl-Z respectively.

  • IEXTEN: local bitflag that enables Ctrl-V and Ctrl-O signals, that interpret the next character as a literal.

  • VMIN: control character index that represents the minimun number of bytes that read() reads before returning.

  • VTIME: control character index that represents the timeout of read() in tenths of a second.

  • TIOCGWINSZ: TerminalInputOutputControlGetWINdowSiZe

🛸 42 São Paulo

Part of the larger 42 Network, 42 São Paulo is a software engineering school that offers a healthy alternative to traditional education:

  • It doesn't have any teachers and classes.
  • Students learn by cooperating and correcting each other's work (peer-to-peer learning).
  • Its focus is as much on social skills as it is on technical skills.
  • It's completely free to anyone that passes its selection process - The Piscine

It's an amazing school, and I'm grateful for the opportunity.

“I believe 42 will have a rippling effect on the history of the world.” @michaelbrave

The more I study at 42 the more I see the revival of a powerful educational method renewed to a modern discipline. It's not a school in the traditional sense, but more like a Tech Dojo with training and sparring.

Basically the computer nerd version of the Lyceum as opposed to the Apollonian Academy.

📚 Resources