aboutsummaryrefslogtreecommitdiff
path: root/goldfishterm/simple.h
diff options
context:
space:
mode:
Diffstat (limited to 'goldfishterm/simple.h')
-rw-r--r--goldfishterm/simple.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/goldfishterm/simple.h b/goldfishterm/simple.h
index 48a7789..0228749 100644
--- a/goldfishterm/simple.h
+++ b/goldfishterm/simple.h
@@ -17,7 +17,7 @@
#include <termios.h>
-#include <iostream>
+#include <ostream>
#include <vector>
#include "goldfishterm/internal/string_capability.h"
@@ -33,15 +33,14 @@ enum class CursorVisibility {
kVeryVisible,
};
-// Looks up escape sequences for the terminal described in the TERM environment
-// variable, and allows sending those escape sequences to standard output.
+// Looks up escape sequences for the specified terminal and allows sending those
+// escape sequences to the specified ostream.
//
-// This class is thread-safe, provided you don't mutate the TERM environment
-// variable while its constructor is running.
+// This class is thread-safe.
class SimpleTerminalOutput final {
public:
- explicit SimpleTerminalOutput();
- explicit SimpleTerminalOutput(const termios&);
+ explicit SimpleTerminalOutput(absl::string_view terminal_name, const termios&,
+ std::ostream&);
SimpleTerminalOutput(const SimpleTerminalOutput&) noexcept = default;
SimpleTerminalOutput& operator=(const SimpleTerminalOutput&) noexcept =
@@ -49,9 +48,9 @@ class SimpleTerminalOutput final {
SimpleTerminalOutput(SimpleTerminalOutput&&) noexcept = default;
SimpleTerminalOutput& operator=(SimpleTerminalOutput&&) noexcept = default;
- void Write(absl::string_view s) { std::cout.write(s.data(), s.size()); }
+ void Write(absl::string_view s) { out_.write(s.data(), s.size()); }
- void Flush() { std::cout.flush(); }
+ void Flush() { out_.flush(); }
// Rings the bell. On some terminals, this may flash the screen instead.
void Beep() { Emit(StringCapability::kBell); }
@@ -74,6 +73,7 @@ class SimpleTerminalOutput final {
TerminfoEntry terminfo_;
int baud_;
+ std::ostream& out_;
};
} // namespace goldfishterm