Skip to content

Conversation

@staxfur
Copy link
Collaborator

@staxfur staxfur commented Feb 12, 2021

As introduced in #64 and already implemented in #68. I have removed the write funktion from the library, which simply is an alias for std::cout. @certik argument to provide a simple function to hide the "cmplicated" stuff, I think, that std::cout << s << std::flush; is a well known thing in C++ and make the code more clear without hiding the actuall code. But as it's just an optional wrapper, i would understand to just keep it for those, who want a really simple fucntion.

@staxfur staxfur added enhancement New feature or request question Further information is requested labels Feb 12, 2021
@staxfur staxfur requested a review from certik February 12, 2021 21:33
@certik
Copy link
Collaborator

certik commented Feb 12, 2021

I think it's probably fine, but let me think about this one a bit. I don't know how common is to know that you have to call std::flush at the end, otherwise it sometimes does not work.

@certik certik mentioned this pull request Feb 12, 2021
@staxfur
Copy link
Collaborator Author

staxfur commented Feb 12, 2021

Yeah, std::flush forces 'flushing' the iostream, so basically it tells the console to draw out everything that is pending. If I get it right, the terminal or the iostream is not writing to the console imideately, but at the end of the section (the function for example).

@staxfur
Copy link
Collaborator Author

staxfur commented Feb 12, 2021

Small thought:
Is the write() function needed, if the terminal should be used with the Window class in the end? Otherwise you are probably right about providing the write() function. I would still change everything to use that function. There are some std::cout << s << std::flush inside of the code that are not using write().

@certik
Copy link
Collaborator

certik commented Feb 12, 2021

Yes, I noticed that. I think we can probably take the write function out of the class and just have a global function in the term namespace.

I would lean towards keeping the function, at the very least, it is shorter to write

term::write("x");

than

std::cout << x << std::flush;

@staxfur staxfur changed the title removed write function Improve write function Feb 12, 2021
@staxfur staxfur closed this Feb 12, 2021
@staxfur staxfur deleted the removeWrite branch February 13, 2021 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants