94 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 95 #error "Only <final/final.h> can be included directly." 98 #include "final/fconfig.h" 100 #include <sys/ioctl.h> 101 #include <sys/stat.h> 104 #include <langinfo.h> 106 #if defined(F_HAVE_GETTTYNAM) && defined(F_HAVE_TTYENT_H) 114 #include <functional> 120 #include "final/fc.h" 121 #include "final/output/fcolorpalette.h" 122 #include "final/output/tty/ftermcap.h" 123 #include "final/output/tty/ftermdata.h" 124 #include "final/output/tty/fterm_functions.h" 125 #include "final/util/fstring.h" 126 #include "final/util/fsystem.h" 148 using FSetPalette = FColorPalette::FSetPalette;
163 auto operator = (
const FTerm&) ->
FTerm& =
delete;
166 auto operator = (
FTerm&&) noexcept ->
FTerm& =
delete;
169 static auto getClassName() ->
FString;
170 static auto getLineNumber() -> std::size_t;
171 static auto getColumnNumber() -> std::size_t;
172 static auto getKeyName (FKey) ->
FString;
174 static auto getTTYFileDescriptor() -> int;
175 static auto getTermType() -> std::string;
176 static auto getTermFileName() -> std::string;
177 static auto getTabstop() -> int;
178 static auto getMaxColor() -> int;
181 static auto isRaw() -> bool;
182 static auto hasUTF8() -> bool;
183 static auto isMonochron() -> bool;
184 static auto isNewFont() -> bool;
185 static auto isInitialized() -> bool;
186 static auto isCursorHideable() -> bool;
187 static auto isEncodable (
const wchar_t&) -> bool;
188 static auto hasChangedTermSize() -> bool;
189 static auto hasShadowCharacter() -> bool;
190 static auto hasHalfBlockCharacter() -> bool;
191 static auto hasAlternateScreen() -> bool;
192 static auto canChangeColorPalette() -> bool;
195 static void setFSystem (std::unique_ptr<FSystem>&);
196 static void setTermType (
const std::string&);
197 static void setInsertCursor (
bool =
true);
198 static void unsetInsertCursor();
199 static void redefineDefaultColors (
bool =
true);
200 static void setDblclickInterval (
const uInt64);
201 static void useAlternateScreen (
bool =
true);
202 static void setUTF8 (
bool =
true);
203 static void unsetUTF8();
206 static auto setVGAFont() -> bool;
207 static auto setNewFont() -> bool;
208 static auto resetFont() -> bool;
209 static auto openConsole() -> int;
210 static auto closeConsole() -> int;
213 static void detectTermSize();
214 static void setTermSize (
const FSize&);
215 static void setTermTitle (
const FString&);
216 static void setKDECursor (KdeKonsoleCursorShape);
217 static void saveColorMap();
218 static void resetColorMap();
219 static void clearTerminalAttributes();
220 static void setPalette (FColor,
int,
int,
int);
221 static void setBeep (
int,
int);
222 static void resetBeep();
225 static void setEncoding (Encoding);
226 static auto getEncodingString() -> std::string;
227 static auto charEncode (
const wchar_t&) -> wchar_t;
228 static auto charEncode (
const wchar_t&,
const Encoding&) -> wchar_t;
230 static auto scrollTermForward() -> bool;
231 static auto scrollTermReverse() -> bool;
233 template <
typename... Args>
234 static void paddingPrintf (Args&&...);
236 static void paddingPrint (
const char*, uInt32,
int = 1);
237 static void paddingPrint (
const char*,
int = 1);
238 static void stringPrint (
const char*, uInt32);
241 static void initScreenSettings();
242 static void changeTermSizeFinished();
247 static void init_global_values();
248 static void init_terminal_device_path();
249 static void oscPrefix();
250 static void oscPostfix();
251 static void init_alt_charset();
252 static void init_pc_charset();
253 static auto configEnterPcCharsetMode() -> bool;
254 static auto configExitPcCharsetMode() -> bool;
255 static void init_cygwin_charmap();
256 static void updatePCEncodingForCygwin();
257 static void updateCharMappingForCygwin();
258 static void init_teraterm_charmap();
259 static void init_fixed_max_color();
260 static void init_termcap();
261 static void init_quirks();
262 static void init_optiMove();
263 static void init_optiAttr();
264 static auto init_font() -> bool;
265 static void init_locale();
266 static auto init_xterm_locale (
const char*) ->
const char*;
267 static auto init_tera_term_locale (
const char*) ->
const char*;
268 static auto init_kterm_locale (
const char*) ->
const char*;
269 static auto init_sun_locale (
const char*) ->
const char*;
270 static auto init_locale_if_not_found (
const char*) ->
const char*;
271 static void init_encoding();
272 static void init_encoding_set();
273 static void init_term_encoding();
274 static void init_individual_term_encoding();
275 static void init_force_vt100_encoding();
276 static void init_utf8_without_alt_charset();
277 static void init_tab_quirks();
278 static void init_captureFontAndTitle();
279 static auto hasNoFontSettingOption() -> bool;
280 static auto canSetTerminalFont() -> bool;
281 static void setInsertCursorStyle();
282 static void setOverwriteCursorStyle();
285 static void enableMouse();
286 static void disableMouse();
287 static void enableApplicationEscKey();
288 static void disableApplicationEscKey();
289 static void enableKeypad();
290 static void disableKeypad();
291 static void enableAlternateCharset();
292 static void useAlternateScreenBuffer();
293 static void useNormalScreenBuffer();
295 auto init_terminal()
const -> bool;
296 void initOSspecifics()
const;
297 void initTermspecifics()
const;
298 void initBaudRate()
const;
300 void finishOSspecifics()
const;
301 void finish_encoding()
const;
302 static void printExitMessage();
303 static void terminalSizeChange();
304 [[noreturn]]
static void processTermination (
int);
305 static void setSignalHandler();
306 static void resetSignalHandler();
307 static void signal_handler (
int);
313 inline auto FTerm::getClassName() ->
FString 317 inline auto FTerm::getTabstop() ->
int 318 {
return FTermcap::tabstop; }
321 inline auto FTerm::getMaxColor() ->
int 322 {
return FTermcap::max_color; }
325 inline auto FTerm::hasUTF8() ->
bool 327 static const auto& fterm_data = FTermData::getInstance();
328 return fterm_data.hasUTF8Console();
332 inline auto FTerm::isMonochron() ->
bool 334 static const auto& fterm_data = FTermData::getInstance();
335 return fterm_data.isMonochron();
339 inline auto FTerm::isNewFont() ->
bool 341 static const auto& fterm_data = FTermData::getInstance();
342 return fterm_data.isNewFont();
346 inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
348 FSystem::getInstance().swap(fsystem);
352 inline void FTerm::unsetInsertCursor()
353 { setInsertCursor(
false); }
356 inline void FTerm::unsetUTF8()
360 template <
typename... Args>
361 inline void FTerm::paddingPrintf (Args&&... args)
363 const int size = std::snprintf (
nullptr, 0, args...);
368 std::string buffer{};
369 auto buffer_size = std::size_t(size) + 1;
370 buffer.resize(buffer_size);
371 std::snprintf ( &*buffer.begin(), buffer_size
372 , std::forward<Args>(args)... );
374 buffer.resize(buffer_size);
375 paddingPrint (buffer.c_str(), uInt32(size), 1);
379 inline void FTerm::initTerminal()
385 inline auto operator << (std::ostream& os, finalcut::UniChar c) -> std::ostream&
387 static const auto& data = finalcut::FTermData::getInstance();
389 if ( data.getTerminalEncoding() == finalcut::Encoding::UTF8 )
391 std::array<char, 4> buf{};
392 const uInt32 len = finalcut::UTF8::encode(
wchar_t(c), buf);
393 return os.write(&buf[0], len);
396 return os << static_cast<char>(uChar(c));
400 inline auto operator << (std::wostream& os, finalcut::UniChar c) -> std::wostream&
402 return os << static_cast<wchar_t>(c);
Definition: ftermcap.h:72
Definition: ftermdata.h:58
Definition: class_template.cpp:25
Definition: fstartoptions.h:52