OSDN Git Service

[Refactor] #39964 Moved kill_line_segment() from autopick.c to autopick-inserter.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 25 Apr 2020 16:45:06 +0000 (01:45 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 25 Apr 2020 16:45:06 +0000 (01:45 +0900)
src/autopick/autopick-inserter.c
src/autopick/autopick-inserter.h
src/autopick/autopick.c

index 3d7b061..d008e36 100644 (file)
@@ -198,3 +198,41 @@ void insert_single_letter(text_body_type *tb, int key)
        check_expression_line(tb, tb->cy);
        tb->changed = TRUE;
 }
+
+
+/*
+ * Kill segment of a line
+ */
+void kill_line_segment(text_body_type *tb, int y, int x0, int x1, bool whole)
+{
+       concptr s = tb->lines_list[y];
+       if (whole && x0 == 0 && s[x1] == '\0' && tb->lines_list[y + 1])
+       {
+               string_free(tb->lines_list[y]);
+
+               int i;
+               for (i = y; tb->lines_list[i + 1]; i++)
+                       tb->lines_list[i] = tb->lines_list[i + 1];
+               tb->lines_list[i] = NULL;
+
+               tb->dirty_flags |= DIRTY_EXPRESSION;
+
+               return;
+       }
+
+       if (x0 == x1) return;
+
+       char buf[MAX_LINELEN];
+       char *d = buf;
+       for (int x = 0; x < x0; x++)
+               *(d++) = s[x];
+
+       for (int x = x1; s[x]; x++)
+               *(d++) = s[x];
+
+       *d = '\0';
+       string_free(tb->lines_list[y]);
+       tb->lines_list[y] = string_make(buf);
+       check_expression_line(tb, y);
+       tb->changed = TRUE;
+}
index 005464c..b690655 100644 (file)
@@ -5,3 +5,4 @@ bool insert_return_code(text_body_type *tb);
 bool insert_macro_line(text_body_type *tb);
 bool insert_keymap_line(text_body_type *tb);
 void insert_single_letter(text_body_type *tb, int key);
+void kill_line_segment(text_body_type *tb, int y, int x0, int x1, bool whole);
index 0c74793..cd1f2e9 100644 (file)
@@ -833,44 +833,6 @@ static void copy_text_to_yank(text_body_type *tb)
 
 
 /*
- * Kill segment of a line
- */
-static void kill_line_segment(text_body_type *tb, int y, int x0, int x1, bool whole)
-{
-       concptr s = tb->lines_list[y];
-       if (whole && x0 == 0 && s[x1] == '\0' && tb->lines_list[y + 1])
-       {
-               string_free(tb->lines_list[y]);
-
-               int i;
-               for (i = y; tb->lines_list[i + 1]; i++)
-                       tb->lines_list[i] = tb->lines_list[i + 1];
-               tb->lines_list[i] = NULL;
-
-               tb->dirty_flags |= DIRTY_EXPRESSION;
-
-               return;
-       }
-
-       if (x0 == x1) return;
-
-       char buf[MAX_LINELEN];
-       char *d = buf;
-       for (int x = 0; x < x0; x++)
-               *(d++) = s[x];
-
-       for (int x = x1; s[x]; x++)
-               *(d++) = s[x];
-
-       *d = '\0';
-       string_free(tb->lines_list[y]);
-       tb->lines_list[y] = string_make(buf);
-       check_expression_line(tb, y);
-       tb->changed = TRUE;
-}
-
-
-/*
  * Execute a single editor command
  */
 static bool do_editor_command(player_type *player_ptr, text_body_type *tb, int com_id)