OSDN Git Service

[Feature] term_eraseで画面右端まで消去する機能
authorHabu <habu1010+github@gmail.com>
Sat, 15 Jul 2023 12:23:15 +0000 (21:23 +0900)
committerHabu <habu1010+github@gmail.com>
Sat, 15 Jul 2023 12:23:15 +0000 (21:23 +0900)
消去するカラム数を指定する引数をstd::optionalにし、std::nulloptが指定
された場合は画面右端まで消去を行う。

src/term/z-term.cpp
src/term/z-term.h

index 5ff5a8d..5f19c7b 100644 (file)
@@ -1604,7 +1604,7 @@ errr term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, std::string_view s
 /*
  * Place cursor at (x,y), and clear the next "n" chars
  */
-errr term_erase(TERM_LEN x, TERM_LEN y, int n)
+errr term_erase(TERM_LEN x, TERM_LEN y, std::optional<int> n_opt)
 {
     TERM_LEN w = game_term->wid;
     /* int h = Term->hgt; */
@@ -1623,6 +1623,8 @@ errr term_erase(TERM_LEN x, TERM_LEN y, int n)
     x = game_term->scr->cx;
     y = game_term->scr->cy;
 
+    auto n = n_opt.value_or(w);
+
     /* Force legal size */
     if (x + n > w) {
         n = w - x;
index e1d8f0f..ffffcad 100644 (file)
@@ -208,7 +208,7 @@ errr term_add_bigch(TERM_COLOR a, char c);
 errr term_addstr(int n, TERM_COLOR a, std::string_view sv);
 errr term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
 errr term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, std::string_view sv);
-errr term_erase(TERM_LEN x, TERM_LEN y, int n);
+errr term_erase(TERM_LEN x, TERM_LEN y, std::optional<int> n_opt = std::nullopt);
 errr term_clear(void);
 errr term_redraw(void);
 errr term_redraw_section(TERM_LEN x1, TERM_LEN y1, TERM_LEN x2, TERM_LEN y2);