Hacker News new | ask | show | jobs
by pdkl95 3522 days ago
> 400 lines of code to wait for keyboard input.. sweet Jesus.

That function isn't particularly bad. It's a little messy, but it's reasonable for legacy portable code.

>> This function is over 400 lines and contains over 40 #ifdefs.

This is a low-level function that is supposed to handle different platforms, so this is the function where platform-specific #ifdefs should be collected. It's mostly a giant case/switch style #ifdef wrapper around a list of platforms and features.

>> Vim tries to be compatible with every OS, including dead ones such as BeOS, VMS, and Amiga.

That isn't a bad thing. Unless there is an actual[1] problem with the legacy platform support, then it should be left in for the people that do use the "dead" OS.

> Features that drastically change behavior are enabled/disabled with preprocessor flags.

Yes, that's the point of those flags. This is to enable/disable major features like XCLIPBOARD support which isn't going to compile on non-X11 platforms, or for debug and other unusual features that shouldn't be included in standard builds.

> Cross-platform libraries like libuv didn’t exist when Vim was created.

Sure. Which is why this function exists. Also, libuv is nice, but it isn't a replacement for all of the features (like XCLIPBOARD) this function provides. Even if most of the function was replaced with a libuv port, some of the #ifdefs would still be necessary.

[1] "It's old" doesn't count.