OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / main-unix / x11-type-string.cpp
1 /*!
2  * @file x11-type-string.cpp
3  * @brief X11用の文字列処理
4  * @date 2020/06/14
5  * @author Hourier
6  * @details Windowsでは使わない
7  */
8
9 #include "main-unix/x11-type-string.h"
10 #include "term/gameterm.h"
11
12 /*
13  * Add a series of keypresses to the "queue".
14  *
15  * Return any errors generated by term_key_push() in doing so, or SUCCESS
16  * if there are none.
17  *
18  * Catch the "out of space" error before anything is printed.
19  *
20  * NB: The keys added here will be interpreted by any macros or keymaps.
21  */
22 errr type_string(concptr str, uint len)
23 {
24     errr err = 0;
25     term_type *old = game_term;
26     if (!str) {
27         return -1;
28     }
29     if (!len) {
30         len = strlen(str);
31     }
32
33     term_activate(term_screen);
34     for (concptr s = str; s < str + len; s++) {
35         if (*s == '\0') {
36             break;
37         }
38
39         err = term_key_push(*s);
40         if (err) {
41             break;
42         }
43     }
44
45     term_activate(old);
46     return err;
47 }