-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
platform: refactor Win32ConsoleStrategy
The current platform classes have many issues. One of them is that they interact with the terminal in the constructor. This makes it impossible for an strategy to "fail" so that we can fall back on another one, unless we use exceptions, which I'm not willing to use because I think they are not the best solution. This commit changes several things: first, it fixes the "fail" issue for Win32ConsoleStrategy by hiding the constructor and having a public static 'create' function which returns nullptr on error. Second, it reduces the amount of state by splitting the member variables between Win32Input and Win32Display, so that these don't need a reference to Win32ConsoleStrategy. Third, it moves the handle ownership handling to StdioCtl, so that the global TermIO::consoleWrite can be unified. The console detection has also been improved and it is now more resilient and it finally supports spawning a new console when none is available (fixes #25). There's still room for improvement. I look forward to having just PlatformStrategy as singleton instead of StdioCtl. StdioCtl functionality should be moved into PlatformStrategy, and TermIO functions would receive a pointer to PlatformStrategy instead of referring to the StdioCtl singleton. StdioCtl is currently the equivalent of passing parameters by global variables. Also, it can be seen clearly that the resource lifetime of StdioCtl on Windows is tied to Win32ConsoleStrategy's lifetime. This is why I believe they should both be part of the same object.
- Loading branch information
Showing
12 changed files
with
351 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.