/*!
- * todo 長過ぎる、要関数分割
* @brief 自動拾いエディタを表示させる
* @date 2020/04/26
* @author Hourier
#include "gameterm.h"
#include "files.h"
+
+static void process_dirty_expression(player_type *player_ptr, text_body_type *tb)
+{
+ if (tb->dirty_flags & DIRTY_EXPRESSION == 0) return;
+
+ byte state = 0;
+ for (int y = 0; tb->lines_list[y]; y++)
+ {
+ concptr s = tb->lines_list[y];
+ char *ss, *s_keep;
+ tb->states[y] = state;
+
+ if (*s++ != '?') continue;
+ if (*s++ != ':') continue;
+
+ if (streq(s, "$AUTOREGISTER"))
+ state |= LSTAT_AUTOREGISTER;
+
+ int s_len = strlen(s);
+ ss = (char *)string_make(s);
+ s_keep = ss;
+
+ char f;
+ concptr v = process_pref_file_expr(player_ptr, &ss, &f);
+ if (streq(v, "0")) state |= LSTAT_BYPASS;
+ else state &= ~LSTAT_BYPASS;
+
+ C_KILL(s_keep, s_len + 1, char);
+ tb->states[y] = state | LSTAT_EXPRESSION;
+ }
+
+ tb->dirty_flags |= DIRTY_ALL;
+}
+
+
/*
* Draw text
*/
void draw_text_editor(player_type *player_ptr, text_body_type *tb)
{
- int i;
int by1 = 0, by2 = 0;
Term_get_size(&tb->wid, &tb->hgt);
#ifdef JP
/* Don't let cursor at second byte of kanji */
- for (i = 0; tb->lines_list[tb->cy][i]; i++)
+ for (int i = 0; tb->lines_list[tb->cy][i]; i++)
if (iskanji(tb->lines_list[tb->cy][i]))
{
i++;
{
char buf[MAX_LINELEN];
int sepa_length = tb->wid;
- for (i = 0; i < sepa_length; i++)
+ for (int i = 0; i < sepa_length; i++)
buf[i] = '-';
- buf[i] = '\0';
+ buf[sepa_length] = '\0';
Term_putstr(0, tb->hgt + 1, sepa_length, TERM_WHITE, buf);
}
- if (tb->dirty_flags & DIRTY_EXPRESSION)
- {
- byte state = 0;
- for (int y = 0; tb->lines_list[y]; y++)
- {
- char f;
- concptr v;
- concptr s = tb->lines_list[y];
- char *ss, *s_keep;
- int s_len;
-
- tb->states[y] = state;
-
- if (*s++ != '?') continue;
- if (*s++ != ':') continue;
-
- if (streq(s, "$AUTOREGISTER"))
- state |= LSTAT_AUTOREGISTER;
-
- s_len = strlen(s);
- ss = (char *)string_make(s);
- s_keep = ss;
-
- v = process_pref_file_expr(player_ptr, &ss, &f);
-
- if (streq(v, "0")) state |= LSTAT_BYPASS;
- else state &= ~LSTAT_BYPASS;
-
- C_KILL(s_keep, s_len + 1, char);
-
- tb->states[y] = state | LSTAT_EXPRESSION;
- }
-
- tb->dirty_flags |= DIRTY_ALL;
- }
-
+ process_dirty_expression(player_ptr, tb);
if (tb->mark)
{
tb->dirty_flags |= DIRTY_ALL;
by2 = MAX(tb->my, tb->cy);
}
- for (i = 0; i < tb->hgt; i++)
+ int erase_height = 0;
+ for (int i = 0; i < tb->hgt; i++)
{
int leftcol = 0;
concptr msg;
if (x0 < bx2) Term_addstr(bx2 - bx1, TERM_YELLOW, msg + (bx1 - x0));
Term_addstr(-1, color, msg + (bx2 - x0));
}
+
+ erase_height++;
}
- for (; i < tb->hgt; i++)
+ for (int i = erase_height; i < tb->hgt; i++)
{
Term_erase(0, i + 1, tb->wid);
}
autopick_type an_entry, *entry = &an_entry;
concptr str1 = NULL, str2 = NULL;
- for (i = 0; i < DESCRIPT_HGT; i++)
+ for (int i = 0; i < DESCRIPT_HGT; i++)
{
Term_erase(0, tb->hgt + 2 + i, tb->wid);
}
roff_to_buf(buf, 81, temp, sizeof(temp));
t = temp;
- for (i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
if (t[0] == 0)
break;
t += strlen(t) + 1;
}
}
+
autopick_free_entry(entry);
}