Chapter 122
Chapter 122
In March, Beichuan gets warmer day by day.
Lin Feng sat at his desk, staring at the code on the computer screen. The cursor blinked on the last line, as if waiting for his next command.
The text editor is mostly finished, and the basic functions are implemented—creating, opening, saving, and saving as files; moving, selecting, copying, pasting, and cutting the cursor in the editing area; and finding and replacing.
Syntax highlighting is still missing.
This feature was commonplace in the past, present in every editor. But in 1996, implementing syntax highlighting in Borland C++ on Windows 3.2 was no easy task.
The challenge lies in the fact that the editor controls in Windows 3.2 do not support different text colors. To achieve syntax highlighting, you have to draw it yourself.
Lin Feng has already written a custom control that takes over the text drawing process. The task now is to parse the code—identify keywords, strings, comments, and numbers—and assign them different colors.
He opened a new file and began writing the lexical analyzer.
First, he defined the list of C language keywords—int, char, if, else, for, while, return… a total of thirty-two. He typed them in one by one, his fingers clattering across the keyboard.
Then comes string recognition—when a double quote is encountered, everything from that double quote until the next double quote is considered a string and is represented by the same color.
Then there are comments—starting with /* and ending with */, everything in between is a comment, and they are displayed in a different color. Single-line comments // should also be supported.
Then there are the numbers—0 to 9 appearing consecutively, count the numbers, and then use a different color.
He wrote it down line by line, tested it after finishing, revised it after testing, and tested it again after revising it.
I worked on it until 10 p.m., and the syntax highlighting was basically working. Although there were still some minor bugs—keywords in strings were sometimes misrecognized, and the handling of nested comments was not perfect—it was generally readable.
He opened a C language source file, and colors immediately appeared on the screen: keywords were blue, strings were green, comments were gray, numbers were red, and the rest were black.
He looked at the colors and smiled.
This is his first original software.
It wasn't translated into Chinese, nor was it copied; he wrote it line by line, line by line.
He named the software CodeLight.
Light of Code.
Simple, easy to remember, and—light is his obsession across lifetimes. In his past life, he sat in darkness for forty-three years; in this life, he wants to shine.
He saved the code, compiled it, and generated an executable file. Then he copied it to a floppy disk and wrote on the floppy disk label: CodeLight v0.1.
Then he turned off his computer and lay down on the bed.
Thinking about the next step.
v0.1 is just a prototype; it works, but it's not great. Syntax highlighting only supports C; it needs to be added—at least C++, BASIC, and Pascal should be supported. The find and replace function is too basic; regular expression support needs to be added. There's no automatic indentation; that needs to be added. There's no line number display; that needs to be added. There's no multi-file tab page; that needs to be added.
There are too many things to add.
He turned over and looked out the window.
The moonlight was very bright, shining on the curtains and making them appear white.
He suddenly remembered something.
In his past life, the first editor he used was Notepad++. It was written by a Taiwanese person; it was open-source, free, powerful, and hadn't become obsolete for decades.
He closed his eyes.
If an editor like Notepad++ could be created, it would definitely be a blockbuster in this era.
But he doesn't intend to offer it for free.
He used so much free software in his past life because he was poor. In this life, he doesn't want to be poor.
socalfunplaces