Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore Output if line is finished #72

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions inkcpp/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,17 @@ char* basic_stream::get_alloc(string_table& strings, list_table& lists)
_size = start;

// Return processed string
end = clean_string<true, false>(buffer, buffer + c_str_len(buffer));
*end = 0;
_last_char = end[-1];
if constexpr (RemoveTail) {
if (_last_char == ' ') {
end[-1] = 0;
end = clean_string<true, false>(buffer, buffer + c_str_len(buffer));
*end = 0;
if (end != buffer) {
_last_char = end[-1];
if constexpr (RemoveTail) {
if (_last_char == ' ') {
end[-1] = 0;
}
}
} else {
_last_char = 'e';
}

return buffer;
Expand All @@ -365,9 +369,8 @@ size_t basic_stream::find_start() const
if (_save != ~0 && start < _save) {
// TODO: check if we don't reset save correct
// at some point we can modifiy the output even behind save (probally discard?) and push a new
// element -> invalid save point inkAssert(false, "Trying to access output stream prior to save
// point!");
const_cast<basic_stream&>(*this).clear();
// element -> invalid save point
inkAssert(false, "Trying to access output stream prior to save point!");
}

return start;
Expand Down
3 changes: 3 additions & 0 deletions inkcpp/runner_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ void runner_impl::advance_line()
// can be in save state becaues of choice
// Garbage collection TODO: How often do we want to do this?
_globals->gc();
if (_output.saved()) {
_output.restore();
}
}

bool runner_impl::can_continue() const { return _ptr != nullptr; }
Expand Down
Loading
Loading