-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from KazDragon/terminal-manip#139
Terminal manip#139
- Loading branch information
Showing
18 changed files
with
647 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates mouse disable operation | ||
//* ========================================================================= | ||
struct disable_mouse | ||
{ | ||
//* ===================================================================== | ||
/// \brief Disables the mouse in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.disable_mouse(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates mouse enable operation | ||
//* ========================================================================= | ||
struct enable_mouse | ||
{ | ||
//* ===================================================================== | ||
/// \brief Enables the mouse in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.enable_mouse(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates an erase in display operation | ||
//* ========================================================================= | ||
struct erase_in_display | ||
{ | ||
//* ===================================================================== | ||
/// \brief Constructor | ||
//* ===================================================================== | ||
constexpr explicit erase_in_display(terminal::erase_display how) | ||
: how_(how) | ||
{ | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Erases some of the display of the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.erase_in_display(how_); | ||
} | ||
|
||
terminal::erase_display how_; | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates an erase in line operation | ||
//* ========================================================================= | ||
struct erase_in_line | ||
{ | ||
//* ===================================================================== | ||
/// \brief Constructor | ||
//* ===================================================================== | ||
constexpr explicit erase_in_line(terminal::erase_line how) | ||
: how_(how) | ||
{ | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Erases some of the line in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.erase_in_line(how_); | ||
} | ||
|
||
terminal::erase_line how_; | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a cursor hide operation | ||
//* ========================================================================= | ||
struct hide_cursor | ||
{ | ||
//* ===================================================================== | ||
/// \brief Hides the cursor in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.hide_cursor(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a cursor move operation | ||
//* ========================================================================= | ||
struct move_cursor | ||
{ | ||
//* ===================================================================== | ||
/// \brief Constructor | ||
//* ===================================================================== | ||
constexpr explicit move_cursor(terminalpp::point position) | ||
: position_(position) | ||
{ | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Moves the cursor in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.move_cursor(position_); | ||
} | ||
|
||
terminalpp::point position_; | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a cursor restore operation | ||
//* ========================================================================= | ||
struct restore_cursor | ||
{ | ||
//* ===================================================================== | ||
/// \brief Restores the cursor in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.restore_cursor(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a cursor save operation | ||
//* ========================================================================= | ||
struct save_cursor | ||
{ | ||
//* ===================================================================== | ||
/// \brief Saves the cursor in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.save_cursor(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a set window title operation | ||
//* ========================================================================= | ||
struct set_window_title | ||
{ | ||
//* ===================================================================== | ||
/// \brief Constructor | ||
//* ===================================================================== | ||
explicit set_window_title(std::string const &title) | ||
: title_(title) | ||
{ | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Sets the window title in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.set_window_title(title_); | ||
} | ||
|
||
std::string const &title_; | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a cursor show operation | ||
//* ========================================================================= | ||
struct show_cursor | ||
{ | ||
//* ===================================================================== | ||
/// \brief Shows the cursor in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.show_cursor(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
#include "terminalpp/core.hpp" | ||
#include <string> | ||
|
||
namespace terminalpp { | ||
|
||
class terminal; | ||
class string; | ||
|
||
//* ========================================================================= | ||
/// \brief A class that encapsulates commands being streamed to a terminal. | ||
//* ========================================================================= | ||
class terminal_streamer | ||
{ | ||
public : | ||
//* ===================================================================== | ||
/// \brief Constructor | ||
//* ===================================================================== | ||
explicit terminal_streamer(terminal &term) | ||
: terminal_(term) | ||
{ | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Converts the result of the streaming operation to a string. | ||
//* ===================================================================== | ||
operator std::string() const | ||
{ | ||
return result_; | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Streams an operation into the streamer. | ||
//* ===================================================================== | ||
template <class Op> | ||
terminal_streamer &operator<<(Op &&op) | ||
{ | ||
result_ += op(terminal_); | ||
return *this; | ||
} | ||
|
||
//* ===================================================================== | ||
/// \brief Streams a string into the streamer. | ||
//* ===================================================================== | ||
TERMINALPP_EXPORT | ||
terminal_streamer &operator<<(string const &text); | ||
|
||
//* ===================================================================== | ||
/// \brief Streams a string into the streamer. | ||
//* ===================================================================== | ||
TERMINALPP_EXPORT | ||
terminal_streamer &operator<<(string &&text); | ||
|
||
private : | ||
terminal &terminal_; | ||
std::string result_; | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a use alternate screen buffer | ||
/// operation. | ||
//* ========================================================================= | ||
struct use_alternate_screen_buffer | ||
{ | ||
//* ===================================================================== | ||
/// \brief Uses the alternate screen buffer in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.use_alternate_screen_buffer(); | ||
} | ||
}; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "terminalpp/terminal.hpp" | ||
|
||
namespace terminalpp { | ||
|
||
//* ========================================================================= | ||
/// \brief A structure that encapsulates a use normal screen buffer operation | ||
//* ========================================================================= | ||
struct use_normal_screen_buffer | ||
{ | ||
//* ===================================================================== | ||
/// \brief Uses the normal screen buffer in the terminal. | ||
//* ===================================================================== | ||
std::string operator()(terminal &term) | ||
{ | ||
return term.use_normal_screen_buffer(); | ||
} | ||
}; | ||
|
||
} |
Oops, something went wrong.