| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746 |
- /******************************************************************************
- * This file is part of TinTin++ *
- * *
- * Copyright 2004-2020 Igor van den Hoven *
- * *
- * TinTin++ is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 3 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with TinTin++. If not, see https://www.gnu.org/licenses. *
- ******************************************************************************/
- /******************************************************************************
- * T I N T I N + + *
- * *
- * coded by Igor van den Hoven 2006 *
- ******************************************************************************/
- #include "tintin.h"
- DO_COMMAND(do_cursor)
- {
- char all[BUFFER_SIZE], arg1[BUFFER_SIZE], temp[BUFFER_SIZE];
- int cnt;
- get_arg_in_braces(ses, arg, all, GET_ALL);
- arg = get_arg_in_braces(ses, arg, arg1, GET_ONE);
- // arg = sub_arg_in_braces(ses, arg, arg2, GET_ALL, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- tintin_header(ses, " CURSOR OPTIONS ");
- for (cnt = 0 ; *cursor_table[cnt].fun ; cnt++)
- {
- if (*cursor_table[cnt].name)
- {
- convert_meta(cursor_table[cnt].code, temp, FALSE);
- tintin_printf2(ses, " [%-18s] [%-6s] %s", cursor_table[cnt].name, temp, cursor_table[cnt].desc);
- }
- }
- tintin_header(ses, "");
- }
- else
- {
- for (cnt = 0 ; ; cnt++)
- {
- if (HAS_BIT(cursor_table[cnt].flags, CURSOR_FLAG_GET_ALL))
- {
- if (is_abbrev(all, cursor_table[cnt].name))
- {
- cursor_table[cnt].fun(ses, arg);
- return ses;
- }
- }
- else if (HAS_BIT(cursor_table[cnt].flags, CURSOR_FLAG_GET_ONE))
- {
- if (is_abbrev(arg1, cursor_table[cnt].name))
- {
- cursor_table[cnt].fun(ses, arg);
- return ses;
- }
- }
- else
- {
- break;
- }
- }
- show_error(ses, LIST_COMMAND, "#ERROR: #CURSOR {%s} IS NOT A VALID OPTION.", capitalize(all));
- }
- return ses;
- }
- int inputline_str_str_len(int start, int end)
- {
- int raw_cnt, str_cnt, ret_cnt, width;
- raw_cnt = str_cnt = ret_cnt = 0;
- while (raw_cnt < gtd->input_len)
- {
- if (str_cnt >= end)
- {
- break;
- }
- if (HAS_BIT(gtd->ses->charset, CHARSET_FLAG_UTF8) && is_utf8_head(>d->input_buf[raw_cnt]))
- {
- raw_cnt += get_utf8_width(>d->input_buf[raw_cnt], &width);
- if (str_cnt >= start)
- {
- ret_cnt += width;
- }
- str_cnt += width;
- }
- else
- {
- if (str_cnt >= start)
- {
- ret_cnt++;
- }
- raw_cnt++;
- str_cnt++;
- }
- }
- return ret_cnt;
- }
- // raw range
- int inputline_raw_str_len(int start, int end)
- {
- int raw_cnt, ret_cnt, width;
- raw_cnt = start;
- ret_cnt = 0;
- while (raw_cnt < gtd->input_len)
- {
- if (raw_cnt >= end)
- {
- break;
- }
- if (HAS_BIT(gtd->ses->charset, CHARSET_FLAG_UTF8) && is_utf8_head(>d->input_buf[raw_cnt]))
- {
- raw_cnt += get_utf8_width(>d->input_buf[raw_cnt], &width);
- ret_cnt += width;
- }
- else
- {
- raw_cnt++;
- ret_cnt++;
- }
- }
- return ret_cnt;
- }
- // display range
- int inputline_str_raw_len(int start, int end)
- {
- int raw_cnt, str_cnt, ret_cnt, width, tmp_cnt;
- raw_cnt = str_cnt = ret_cnt = 0;
- while (raw_cnt < gtd->input_len)
- {
- if (str_cnt >= end)
- {
- break;
- }
- if (HAS_BIT(gtd->ses->charset, CHARSET_FLAG_UTF8) && is_utf8_head(>d->input_buf[raw_cnt]))
- {
- tmp_cnt = get_utf8_width(>d->input_buf[raw_cnt], &width);
- if (str_cnt >= start)
- {
- ret_cnt += tmp_cnt;
- }
- raw_cnt += tmp_cnt;
- str_cnt += width;
- }
- else
- {
- if (str_cnt >= start)
- {
- ret_cnt++;
- }
- raw_cnt++;
- str_cnt++;
- }
- }
- return ret_cnt;
- }
- int inputline_raw_raw_len(int start, int end)
- {
- if (start > end)
- {
- return 0;
- }
- return end - start;
- }
- // Get string length of the input area
- int inputline_max_str_len(void)
- {
- return gtd->screen->cols + 1 - gtd->input_off - (HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH) ? 11 : 0);
- }
- int inputline_cur_str_len(void)
- {
- return inputline_str_str_len(gtd->input_hid, gtd->input_hid + inputline_max_str_len());
- }
- // Get the position of the cursor
- int inputline_cur_pos(void)
- {
- return gtd->input_off + gtd->input_pos - gtd->input_hid;
- }
- // Check for invalid characters.
- int inputline_str_chk(int offset, int totlen)
- {
- int size;
- while (offset < totlen)
- {
- if (HAS_BIT(gtd->ses->charset, CHARSET_FLAG_EUC))
- {
- if (is_euc_head(gtd->ses, >d->input_buf[offset]))
- {
- size = get_euc_size(gtd->ses, >d->input_buf[offset]);
- if (size == 1 || offset + size > totlen)
- {
- return FALSE;
- }
- offset += size;
- }
- else
- {
- offset += 1;
- }
- }
- else if (HAS_BIT(gtd->ses->charset, CHARSET_FLAG_UTF8))
- {
- if (is_utf8_head(>d->input_buf[offset]))
- {
- size = get_utf8_size(>d->input_buf[offset]);
- if (size == 1 || offset + size > totlen)
- {
- return FALSE;
- }
- offset += size;
- }
- else
- {
- offset += 1;
- }
- }
- else
- {
- return TRUE;
- }
- }
- return TRUE;
- }
- DO_CURSOR(cursor_backspace)
- {
- if (gtd->input_cur == 0)
- {
- return;
- }
- cursor_left(ses, "");
- cursor_delete(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_brace_open)
- {
- ins_sprintf(>d->input_buf[gtd->input_cur], "{");
- gtd->input_len++;
- gtd->input_cur++;
- gtd->input_pos += inputline_raw_str_len(gtd->input_cur - 1, gtd->input_cur);
- cursor_redraw_line(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_brace_close)
- {
- ins_sprintf(>d->input_buf[gtd->input_cur], "}");
- gtd->input_len++;
- gtd->input_cur++;
- gtd->input_pos += inputline_raw_str_len(gtd->input_cur - 1, gtd->input_cur);
- cursor_redraw_line(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_buffer_down)
- {
- do_buffer(ses, "DOWN");
- }
- DO_CURSOR(cursor_buffer_end)
- {
- do_buffer(ses, "END");
- }
- DO_CURSOR(cursor_buffer_home)
- {
- do_buffer(ses, "HOME");
- }
- DO_CURSOR(cursor_buffer_lock)
- {
- do_buffer(ses, "LOCK");
- }
- DO_CURSOR(cursor_buffer_up)
- {
- do_buffer(ses, "UP");
- }
- DO_CURSOR(cursor_check_line)
- {
- if (gtd->input_pos - gtd->input_hid > inputline_max_str_len() - 3)
- {
- return cursor_redraw_line(ses, "");
- }
- if (gtd->input_hid && gtd->input_pos - gtd->input_hid < 2)
- {
- return cursor_redraw_line(ses, "");
- }
- }
- DO_CURSOR(cursor_check_line_modified)
- {
- if (gtd->input_hid + inputline_max_str_len() < inputline_raw_str_len(0, gtd->input_len))
- {
- return cursor_redraw_line(ses, "");
- }
- return cursor_check_line(ses, "");
- }
- DO_CURSOR(cursor_clear_left)
- {
- if (gtd->input_cur == 0)
- {
- return;
- }
- sprintf(gtd->paste_buf, "%.*s", gtd->input_cur, gtd->input_buf);
- input_printf("\e[%dG\e[%dP", gtd->input_off, gtd->input_pos - gtd->input_hid);
- memmove(>d->input_buf[0], >d->input_buf[gtd->input_cur], gtd->input_len - gtd->input_cur);
- gtd->input_len -= gtd->input_cur;
- gtd->input_buf[gtd->input_len] = 0;
- gtd->input_cur = 0;
- gtd->input_pos = 0;
- cursor_check_line_modified(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_clear_line)
- {
- if (gtd->input_len == 0)
- {
- return;
- }
- sprintf(gtd->paste_buf, "%s", gtd->input_buf);
- input_printf("\e[%dG\e[%dP", gtd->input_off, inputline_cur_str_len());
- gtd->input_len = 0;
- gtd->input_cur = 0;
- gtd->input_hid = 0;
- gtd->input_pos = 0;
- gtd->input_buf[0] = 0;
- modified_input();
- }
- DO_CURSOR(cursor_clear_right)
- {
- if (gtd->input_cur == gtd->input_len)
- {
- return;
- }
- strcpy(gtd->paste_buf, >d->input_buf[gtd->input_cur]);
- input_printf("\e[%dP", inputline_max_str_len() - inputline_str_str_len(gtd->input_hid, gtd->input_pos));
- gtd->input_buf[gtd->input_cur] = 0;
- gtd->input_len = gtd->input_cur;
- modified_input();
- }
- DO_CURSOR(cursor_convert_meta)
- {
- SET_BIT(gtd->flags, TINTIN_FLAG_CONVERTMETACHAR);
- }
- DO_CURSOR(cursor_delete_or_exit)
- {
- if (gtd->input_len == 0)
- {
- cursor_exit(ses, "");
- }
- else
- {
- cursor_delete(ses, "");
- }
- }
- DO_CURSOR(cursor_delete)
- {
- int size, width;
- if (gtd->input_len == 0)
- {
- return;
- }
- if (gtd->input_len == gtd->input_cur)
- {
- return;
- }
- if (HAS_BIT(ses->charset, CHARSET_FLAG_EUC) && is_euc_head(gtd->ses, >d->input_buf[gtd->input_cur]))
- {
- size = get_euc_width(gtd->ses, >d->input_buf[gtd->input_cur], &width);
- gtd->input_len -= size;
- memmove(>d->input_buf[gtd->input_cur], >d->input_buf[gtd->input_cur + size], gtd->input_len - gtd->input_cur + 1);
- if (width)
- {
- input_printf("\e[%dP", width);
- }
- }
- else if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8))
- {
- size = get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- gtd->input_len -= size;
- memmove(>d->input_buf[gtd->input_cur], >d->input_buf[gtd->input_cur + size], gtd->input_len - gtd->input_cur + 1);
- if (width)
- {
- input_printf("\e[%dP", width);
- }
- while (gtd->input_len > gtd->input_cur)
- {
- size = get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- if (width)
- {
- break;
- }
- gtd->input_len -= size;
- memmove(>d->input_buf[gtd->input_cur], >d->input_buf[gtd->input_cur + size], gtd->input_len - gtd->input_cur + 1);
- }
- }
- else
- {
- gtd->input_len--;
- memmove(>d->input_buf[gtd->input_cur], >d->input_buf[gtd->input_cur+1], gtd->input_len - gtd->input_cur + 1);
- input_printf("\e[1P");
- }
- if (gtd->input_hid + inputline_max_str_len() <= inputline_raw_str_len(0, gtd->input_len))
- {
- cursor_redraw_line(ses, "");
- }
- modified_input();
- }
- DO_CURSOR(cursor_delete_word_left)
- {
- int index_cur, width;
- if (gtd->input_cur == 0)
- {
- return;
- }
- index_cur = gtd->input_cur;
- while (gtd->input_cur > 0 && gtd->input_buf[gtd->input_cur - 1] == ' ')
- {
- gtd->input_pos--;
- gtd->input_cur--;
- }
- while (gtd->input_cur > 0 && gtd->input_buf[gtd->input_cur - 1] != ' ')
- {
- if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8))
- {
- if (is_utf8_tail(>d->input_buf[gtd->input_cur]))
- {
- gtd->input_cur--;
- }
- else if (is_utf8_head(>d->input_buf[gtd->input_cur]))
- {
- get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- gtd->input_cur -= 1;
- gtd->input_pos -= width;
- }
- else
- {
- gtd->input_cur--;
- gtd->input_pos--;
- }
- }
- else
- {
- gtd->input_pos--;
- gtd->input_cur--;
- }
- }
- sprintf(gtd->paste_buf, "%.*s", index_cur - gtd->input_cur, >d->input_buf[gtd->input_cur]);
- memmove(>d->input_buf[gtd->input_cur], >d->input_buf[index_cur], gtd->input_len - index_cur + 1);
- // input_printf("\e[%dD\e[%dP", index_cur - gtd->input_cur, index_cur - gtd->input_cur);
- gtd->input_len -= index_cur - gtd->input_cur;
- cursor_redraw_line(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_delete_word_right)
- {
- int index_cur;
- if (gtd->input_cur == gtd->input_len)
- {
- return;
- }
- index_cur = gtd->input_cur;
- while (gtd->input_cur != gtd->input_len && gtd->input_buf[gtd->input_cur] == ' ')
- {
- gtd->input_cur++;
- }
- while (gtd->input_cur != gtd->input_len && gtd->input_buf[gtd->input_cur] != ' ')
- {
- gtd->input_cur++;
- }
- sprintf(gtd->paste_buf, "%.*s", gtd->input_cur - index_cur, >d->input_buf[gtd->input_cur]);
- memmove(>d->input_buf[index_cur], >d->input_buf[gtd->input_cur], gtd->input_len - gtd->input_cur + 1);
- // input_printf("\e[%dP", gtd->input_cur - index_cur);
- gtd->input_len -= gtd->input_cur - index_cur;
- gtd->input_cur = index_cur;
- cursor_redraw_line(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_echo)
- {
- char arg1[BUFFER_SIZE];
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ALL, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- TOG_BIT(ses->telopts, TELOPT_FLAG_ECHO);
- }
- else if (!strcasecmp(arg1, "ON"))
- {
- SET_BIT(ses->telopts, TELOPT_FLAG_ECHO);
- }
- else if (!strcasecmp(arg1, "OFF"))
- {
- DEL_BIT(ses->telopts, TELOPT_FLAG_ECHO);
- }
- else
- {
- show_error(gtd->ses, LIST_COMMAND, "#SYNTAX: #CURSOR {ECHO} {ON|OFF}.");
- }
- }
- DO_CURSOR(cursor_end)
- {
- gtd->input_cur = gtd->input_len;
- gtd->input_pos = inputline_raw_str_len(0, gtd->input_len);
- cursor_redraw_line(ses, "");
- }
- DO_CURSOR(cursor_enter)
- {
- input_printf("\n");
- gtd->input_buf[gtd->input_len] = 0;
- gtd->input_len = 0;
- gtd->input_cur = 0;
- gtd->input_pos = 0;
- gtd->input_off = 1;
- gtd->input_hid = 0;
- gtd->macro_buf[0] = 0;
- gtd->input_tmp[0] = 0;
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH))
- {
- struct listroot *root = ses->list[LIST_HISTORY];
- if (root->update >= 0 && root->update < root->used)
- {
- strcpy(gtd->input_buf, root->list[root->update]->arg1);
- }
- DEL_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH);
- gtd->input_off = 1;
- }
- SET_BIT(gtd->flags, TINTIN_FLAG_PROCESSINPUT);
- modified_input();
- }
- DO_CURSOR(cursor_exit)
- {
- if (ses == gts)
- {
- do_end(ses, "");
- }
- else
- {
- cleanup_session(ses);
- }
- }
- DO_CURSOR(cursor_get)
- {
- char arg1[BUFFER_SIZE];
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ALL, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- show_error(ses, LIST_COMMAND, "#SYNTAX: #CURSOR GET {variable}");
- }
- else
- {
- set_nest_node_ses(ses, arg1, "%s", gtd->input_buf);
- }
- }
- DO_CURSOR(cursor_history_next)
- {
- struct listroot *root = ses->list[LIST_HISTORY];
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH))
- {
- if (root->update == root->used)
- {
- return;
- }
- for (root->update++ ; root->update < root->used ; root->update++)
- {
- if (*gtd->input_buf && find(ses, root->list[root->update]->arg1, gtd->input_buf, SUB_NONE, REGEX_FLAG_NONE))
- {
- break;
- }
- }
- if (root->update < root->used)
- {
- input_printf("\e[%dG \e[0K%.*s\e[%dG", gtd->input_off + inputline_cur_str_len() + 2, gtd->input_off + inputline_max_str_len() - inputline_cur_str_len() - 4, root->list[root->update]->arg1, gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- return;
- }
- if (root->list[0] == NULL)
- {
- return;
- }
- if (!HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYBROWSE))
- {
- return;
- }
- else if (root->update < root->used)
- {
- for (root->update++ ; root->update < root->used ; root->update++)
- {
- if (!strncmp(gtd->input_tmp, root->list[root->update]->arg1, strlen(gtd->input_tmp)))
- {
- break;
- }
- }
- }
- cursor_clear_line(ses, "");
- if (root->update == root->used)
- {
- strcpy(gtd->input_buf, gtd->input_tmp);
- }
- else
- {
- strcpy(gtd->input_buf, root->list[root->update]->arg1);
- }
- gtd->input_len = strlen(gtd->input_buf);
- cursor_end(ses, "");
- SET_BIT(gtd->flags, TINTIN_FLAG_HISTORYBROWSE);
- }
- DO_CURSOR(cursor_history_prev)
- {
- struct listroot *root = ses->list[LIST_HISTORY];
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH))
- {
- if (root->update <= 0)
- {
- return;
- }
- for (root->update-- ; root->update >= 0 ; root->update--)
- {
- if (*gtd->input_buf && find(ses, root->list[root->update]->arg1, gtd->input_buf, SUB_NONE, REGEX_FLAG_NONE))
- {
- break;
- }
- }
- if (root->update >= 0)
- {
- input_printf("\e[%dG \e[0K%.*s\e[%dG", gtd->input_off + inputline_cur_str_len() + 2, gtd->input_off + inputline_max_str_len() - inputline_cur_str_len() - 4, root->list[root->update]->arg1, gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- return;
- }
- if (root->list[0] == NULL)
- {
- return;
- }
- if (!HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYBROWSE))
- {
- strcpy(gtd->input_tmp, gtd->input_buf);
- for (root->update = root->used - 1 ; root->update >= 0 ; root->update--)
- {
- if (!strncmp(gtd->input_tmp, root->list[root->update]->arg1, strlen(gtd->input_tmp)))
- {
- break;
- }
- }
- }
- else if (root->update >= 0)
- {
- for (root->update-- ; root->update >= 0 ; root->update--)
- {
- if (!strncmp(gtd->input_tmp, root->list[root->update]->arg1, strlen(gtd->input_tmp)))
- {
- break;
- }
- }
- }
- cursor_clear_line(ses, "");
- if (root->update == -1)
- {
- strcpy(gtd->input_buf, gtd->input_tmp);
- }
- else
- {
- strcpy(gtd->input_buf, root->list[root->update]->arg1);
- }
- gtd->input_len = strlen(gtd->input_buf);
- cursor_end(ses, "");
- SET_BIT(gtd->flags, TINTIN_FLAG_HISTORYBROWSE);
- }
- DO_CURSOR(cursor_history_search)
- {
- struct listroot *root = ses->list[LIST_HISTORY];
- if (root->list[0] == NULL)
- {
- return;
- }
- if (!HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH))
- {
- strcpy(gtd->input_tmp, gtd->input_buf);
- cursor_clear_line(ses, "");
- SET_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH);
- gtd->input_off = 11;
- root->update = root->used - 1;
- input_printf("(search) [ ] \e[3D");
- }
- else
- {
- if (root->update >= 0 && root->update < root->used)
- {
- strcpy(gtd->input_buf, root->list[root->update]->arg1);
- }
- input_printf("\e[1G\e[0K");
- gtd->input_len = strlen(gtd->input_buf);
- gtd->input_cur = gtd->input_len;
- gtd->input_pos = 0;
- root->update = -1;
- DEL_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH);
- gtd->input_off = 1;
- cursor_redraw_line(ses, "");
- }
- }
- DO_CURSOR(cursor_history_find)
- {
- struct listroot *root = ses->list[LIST_HISTORY];
- push_call("cursor_history_find(%s)", gtd->input_buf);
- if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_EUC))
- {
- if (inputline_str_chk(0, gtd->input_len) == FALSE)
- {
- pop_call();
- return;
- }
- }
- gtd->level->quiet++;
- for (root->update = root->used - 1 ; root->update >= 0 ; root->update--)
- {
- if (*gtd->input_buf && find(ses, root->list[root->update]->arg1, gtd->input_buf, SUB_NONE, REGEX_FLAG_NONE))
- {
- break;
- }
- }
- gtd->level->quiet--;
- if (root->update >= 0)
- {
- input_printf("\e[%dG ] %.*s\e[%dG", gtd->input_off + inputline_cur_str_len(), gtd->input_off + inputline_max_str_len() - inputline_cur_str_len() - 4, root->list[root->update]->arg1, gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- else
- {
- input_printf("\e[%dG ] \e[0K\e[%dG", gtd->input_off + inputline_cur_str_len(), gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- pop_call();
- return;
- }
- DO_CURSOR(cursor_home)
- {
- if (gtd->input_cur == 0)
- {
- return;
- }
- input_printf("\e[%dD", gtd->input_pos - gtd->input_hid);
- gtd->input_cur = 0;
- gtd->input_pos = 0;
- if (gtd->input_hid)
- {
- gtd->input_hid = 0;
- cursor_redraw_line(ses, "");
- }
- }
- DO_CURSOR(cursor_insert)
- {
- char arg1[BUFFER_SIZE];
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ALL, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- TOG_BIT(gtd->flags, TINTIN_FLAG_INSERTINPUT);
- }
- else if (!strcasecmp(arg1, "ON"))
- {
- SET_BIT(gtd->flags, TINTIN_FLAG_INSERTINPUT);
- }
- else if (!strcasecmp(arg1, "OFF"))
- {
- DEL_BIT(gtd->flags, TINTIN_FLAG_INSERTINPUT);
- }
- else
- {
- show_error(gtd->ses, LIST_COMMAND, "#SYNTAX: #CURSOR {INSERT} {ON|OFF}.");
- }
- }
- DO_CURSOR(cursor_left)
- {
- int width;
- if (gtd->input_cur > 0)
- {
- if (HAS_BIT(ses->charset, CHARSET_FLAG_EUC))
- {
- gtd->input_cur--;
- gtd->input_pos--;
- input_printf("\e[1D");
- if (inputline_str_chk(0, gtd->input_cur) == FALSE)
- {
- gtd->input_cur--;
- gtd->input_pos--;
- input_printf("\e[1D");
- }
- }
- else if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8))
- {
- gtd->input_cur--;
- if (gtd->input_cur > 0 && is_utf8_tail(>d->input_buf[gtd->input_cur]))
- {
- do
- {
- gtd->input_cur--;
- }
- while (gtd->input_cur > 0 && is_utf8_tail(>d->input_buf[gtd->input_cur]));
- get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- if (width == 0)
- {
- return cursor_left(ses, "");
- }
- input_printf("\e[%dD", width);
- gtd->input_pos -= width;
- }
- else
- {
- gtd->input_pos--;
- input_printf("\e[1D");
- }
- }
- else
- {
- gtd->input_cur--;
- gtd->input_pos--;
- input_printf("\e[1D");
- }
- cursor_check_line(ses, "");
- }
- }
- DO_CURSOR(cursor_left_word)
- {
- int width;
- // int index_pos;
- if (gtd->input_cur == 0)
- {
- return;
- }
- // index_pos = gtd->input_pos;
- while (gtd->input_cur > 0 && gtd->input_buf[gtd->input_cur - 1] == ' ')
- {
- gtd->input_pos--;
- gtd->input_cur--;
- }
- while (gtd->input_cur > 0 && gtd->input_buf[gtd->input_cur - 1] != ' ')
- {
- gtd->input_cur--;
- if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8))
- {
- if (!is_utf8_tail(>d->input_buf[gtd->input_cur]))
- {
- get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- gtd->input_pos -= width;
- }
- }
- else
- {
- gtd->input_pos--;
- }
- }
- // input_printf("\e[%dD", index_pos - gtd->input_pos);
- cursor_redraw_line(ses, "");
- }
- DO_CURSOR(cursor_paste_buffer)
- {
- if (*gtd->paste_buf == 0)
- {
- return;
- }
- ins_sprintf(>d->input_buf[gtd->input_cur], "%s", gtd->paste_buf);
- gtd->input_len += strlen(gtd->paste_buf);
- gtd->input_cur += strlen(gtd->paste_buf);
- gtd->input_pos += inputline_raw_str_len(gtd->input_cur - strlen(gtd->paste_buf), gtd->input_cur);
- cursor_redraw_line(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_redraw_input)
- {
- if (IS_SPLIT(ses))
- {
- cursor_redraw_line(ses, "");
- }
- else
- {
- /* if (*gtd->ses->scroll->input)
- {
- input_printf("\e[G%s", gtd->ses->scroll->input);
- }*/
- cursor_redraw_line(ses, "");
- /*
- gtd->input_cur = gtd->input_len;
- gtd->input_pos = gtd->input_len % gtd->screen->cols;
- */
- }
- }
- DO_CURSOR(cursor_redraw_line)
- {
- if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8|CHARSET_FLAG_EUC))
- {
- if (inputline_str_chk(0, gtd->input_len) == FALSE)
- {
- return;
- }
- }
- // Erase current input
- input_printf("\e[%dG\e[%dP", gtd->input_off, inputline_max_str_len());
- // Center long lines of input
- if (gtd->input_pos > inputline_max_str_len() - 3)
- {
- while (gtd->input_pos - gtd->input_hid > inputline_max_str_len() - 3)
- {
- gtd->input_hid += inputline_max_str_len() / 2;
- }
- while (gtd->input_pos - gtd->input_hid < 2)
- {
- gtd->input_hid -= inputline_max_str_len() / 2;
- }
- }
- else
- {
- if (gtd->input_hid && gtd->input_pos - gtd->input_hid < 2)
- {
- gtd->input_hid = 0;
- }
- }
- // Print the entire thing
- if (gtd->input_hid)
- {
- if (gtd->input_hid + inputline_max_str_len() >= inputline_raw_str_len(0, gtd->input_len))
- {
- input_printf("<%.*s\e[%dG", inputline_str_raw_len(gtd->input_hid + 1, gtd->input_hid + inputline_max_str_len() - 0), >d->input_buf[inputline_str_raw_len(0, gtd->input_hid + 1)], gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- else
- {
- input_printf("<%.*s>\e[%dG", inputline_str_raw_len(gtd->input_hid + 1, gtd->input_hid + inputline_max_str_len() - 1), >d->input_buf[inputline_str_raw_len(0, gtd->input_hid + 1)], gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- }
- else
- {
- if (gtd->input_hid + inputline_max_str_len() >= inputline_raw_str_len(0, gtd->input_len))
- {
- input_printf("%.*s\e[%dG", inputline_str_raw_len(gtd->input_hid + 0, gtd->input_hid + inputline_max_str_len() - 0), >d->input_buf[inputline_str_raw_len(0, gtd->input_hid + 0)], gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- else
- {
- input_printf("%.*s>\e[%dG", inputline_str_raw_len(gtd->input_hid + 0, gtd->input_hid + inputline_max_str_len() - 1), >d->input_buf[inputline_str_raw_len(0, gtd->input_hid + 0)], gtd->input_off + gtd->input_pos - gtd->input_hid);
- }
- }
- }
- DO_CURSOR(cursor_right)
- {
- int size, width;
- if (gtd->input_cur < gtd->input_len)
- {
- if (HAS_BIT(ses->charset, CHARSET_FLAG_EUC))
- {
- gtd->input_cur += get_euc_width(gtd->ses, >d->input_buf[gtd->input_cur], &width);
- input_printf("\e[%dC", width);
- gtd->input_pos += width;
- }
- else if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8))
- {
- gtd->input_cur += get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- if (width == 0)
- {
- return cursor_right(ses, "");
- }
- input_printf("\e[%dC", width);
- gtd->input_pos += width;
- while (gtd->input_cur < gtd->input_len)
- {
- size = get_utf8_width(>d->input_buf[gtd->input_cur], &width);
- if (width)
- {
- break;
- }
- gtd->input_cur += size;
- }
- }
- else
- {
- input_printf("\e[1C");
- gtd->input_cur++;
- gtd->input_pos++;
- }
- }
- cursor_check_line(ses, "");
- }
- DO_CURSOR(cursor_right_word)
- {
- if (gtd->input_cur == gtd->input_len)
- {
- return;
- }
- while (gtd->input_cur < gtd->input_len && gtd->input_buf[gtd->input_cur] == ' ')
- {
- gtd->input_cur++;
- gtd->input_pos++;
- }
- while (gtd->input_cur < gtd->input_len && gtd->input_buf[gtd->input_cur] != ' ')
- {
- if (!HAS_BIT(ses->charset, CHARSET_FLAG_UTF8) || (gtd->input_buf[gtd->input_cur] & 192) != 128)
- {
- gtd->input_pos++;
- }
- gtd->input_cur++;
- }
- cursor_redraw_line(ses, "");
- }
- DO_CURSOR(cursor_set)
- {
- char arg1[BUFFER_SIZE];
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ALL, SUB_VAR|SUB_FUN);
- if (*arg1 == 0)
- {
- return;
- }
- ins_sprintf(>d->input_buf[gtd->input_cur], "%s", arg1);
- gtd->input_len += strlen(arg1);
- gtd->input_cur += strlen(arg1);
- gtd->input_pos += inputline_raw_str_len(gtd->input_cur - strlen(arg1), gtd->input_cur);
- cursor_redraw_line(ses, "");
- modified_input();
- }
- DO_CURSOR(cursor_suspend)
- {
- do_suspend(ses, "");
- }
- DO_CURSOR(cursor_info)
- {
- tintin_printf2(ses, "Width of input bar: %10d", inputline_max_str_len());
- tintin_printf2(ses, "Offset of input bar: %10d", gtd->input_off);
- tintin_printf2(ses, "Width of hidden text on left: %10d", gtd->input_hid);
- tintin_printf2(ses, "VT100 position of cursor: %10d", gtd->input_pos);
- tintin_printf2(ses, "internal position of cursor: %10d", gtd->input_cur);
- tintin_printf2(ses, "internal length of input line: %10d", gtd->input_len);
- tintin_printf2(ses, "VT100 length of displayed line: %10d", inputline_cur_str_len());
- }
- /*
- Improved tab handling by Ben Love
- */
- int cursor_tab_add(int input_now, int stop_after_first)
- {
- struct listroot *root = gtd->ses->list[LIST_TAB];
- struct listnode *node;
- char tab[BUFFER_SIZE];
- if (!HAS_BIT(root->flags, LIST_FLAG_IGNORE))
- {
- for (root->update = 0 ; root->update < root->used ; root->update++)
- {
- node = root->list[root->update];
- substitute(gtd->ses, node->arg1, tab, SUB_VAR|SUB_FUN);
- if (!strncmp(tab, >d->input_buf[input_now], strlen(>d->input_buf[input_now])))
- {
- if (search_node_list(gtd->ses->list[LIST_COMMAND], tab))
- {
- continue;
- }
- insert_node_list(gtd->ses->list[LIST_COMMAND], tab, "", "", "");
- if (HAS_BIT(node->flags, NODE_FLAG_ONESHOT))
- {
- delete_node_list(gtd->ses, LIST_TAB, node);
- }
- if (stop_after_first)
- {
- return TRUE;
- }
- }
- }
- }
- return FALSE;
- }
- int cursor_auto_tab_add(int input_now, int stop_after_first)
- {
- char tab[BUFFER_SIZE], buf[BUFFER_SIZE];
- int scroll_cnt, line_cnt, tab_len;
- char *arg;
- line_cnt = 0;
- for (scroll_cnt = gtd->ses->scroll->used - 1 ; scroll_cnt > 0 ; scroll_cnt--)
- {
- if (HAS_BIT(gtd->ses->scroll->buffer[scroll_cnt]->flags, BUFFER_FLAG_GREP))
- {
- continue;
- }
- if (line_cnt++ >= gtd->ses->auto_tab)
- {
- break;
- }
- strip_vt102_codes(gtd->ses->scroll->buffer[scroll_cnt]->str, buf);
- arg = buf;
- while (*arg)
- {
- arg = get_arg_in_braces(gtd->ses, arg, tab, GET_ONE);
- if (!strncmp(tab, >d->input_buf[input_now], strlen(>d->input_buf[input_now])))
- {
- tab_len = strlen(tab) -1;
- if (tab_len > 0)
- {
- if (tab[tab_len] == '.' || tab[tab_len] == ',' || tab[tab_len] == ';')
- {
- tab[tab_len] = 0;
- }
- }
- if (search_node_list(gtd->ses->list[LIST_COMMAND], tab))
- {
- continue;
- }
- insert_node_list(gtd->ses->list[LIST_COMMAND], tab, "", "", "");
- if (stop_after_first)
- {
- return TRUE;
- }
- }
- if (*arg == COMMAND_SEPARATOR)
- {
- arg++;
- }
- }
- }
- return FALSE;
- }
- void cursor_hide_completion(int input_now)
- {
- struct listroot *root = gtd->ses->list[LIST_COMMAND];
- struct listnode *f_node;
- struct listnode *l_node;
- int len_change;
- f_node = root->list[0];
- l_node = root->list[root->used - 1];
- if (root->used && !strcmp(l_node->arg1, gtd->input_buf + input_now))
- {
- len_change = strlen(l_node->arg1) - strlen(f_node->arg1);
- if (len_change > 0)
- {
- /*
- if (gtd->input_cur < gtd->input_len)
- {
- input_printf("\e[%dC", gtd->input_len - gtd->input_cur);
- }
- input_printf("\e[%dD\e[%dP", len_change, len_change);
- */
- gtd->input_len = gtd->input_len - len_change;
- gtd->input_buf[gtd->input_len] = 0;
- gtd->input_cur = gtd->input_len;
- gtd->input_pos = gtd->input_pos;
- }
- }
- return;
- }
- void cursor_show_completion(int input_now, int show_last_node)
- {
- struct listroot *root = gtd->ses->list[LIST_COMMAND];
- struct listnode *node;
- if (!root->used)
- {
- return;
- }
- node = show_last_node ? root->list[root->used - 1] : root->list[0];
- /*
- if (gtd->input_cur < gtd->input_len)
- {
- input_printf("\e[%dC", gtd->input_len - gtd->input_cur);
- }
- if (gtd->input_len > input_now)
- {
- input_printf("\e[%dD\e[%dP", gtd->input_len - input_now, gtd->input_len - input_now);
- }
- if (input_now + (int) strlen(node->arg1) < gtd->ses->cols - 2)
- {
- input_printf("%s", node->arg1);
- }
- */
- strcpy(>d->input_buf[input_now], node->arg1);
- gtd->input_len = input_now + strlen(node->arg1);
- gtd->input_cur = gtd->input_len;
- cursor_end(gtd->ses, "");
- if (HAS_BIT(gtd->flags, TINTIN_FLAG_HISTORYSEARCH))
- {
- cursor_history_find(gtd->ses, "");
- }
- if (node == root->list[0])
- {
- kill_list(root);
- }
- return;
- }
- int cursor_calc_input_now(void)
- {
- int input_now;
- if (gtd->input_len == 0 || gtd->input_buf[gtd->input_len - 1] == ' ')
- {
- return -1;
- }
- for (input_now = gtd->input_len - 1 ; input_now ; input_now--)
- {
- if (gtd->input_buf[input_now] == ' ')
- {
- return input_now + 1;
- }
- }
- return input_now;
- }
- DO_CURSOR(cursor_tab)
- {
- char arg1[BUFFER_SIZE];
- int flags;
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ONE, SUB_VAR|SUB_FUN);
- while (*arg)
- {
- if (is_abbrev(arg1, "LIST"))
- {
- SET_BIT(flags, TAB_FLAG_LIST);
- }
- else if (is_abbrev(arg1, "SCROLLBACK"))
- {
- SET_BIT(flags, TAB_FLAG_SCROLLBACK);
- }
- arg = sub_arg_in_braces(ses, arg, arg1, GET_ONE, SUB_VAR|SUB_FUN);
- if (*arg == COMMAND_SEPARATOR)
- {
- arg++;
- }
- }
- if (is_abbrev(arg1, "FORWARD"))
- {
- if (!HAS_BIT(flags, TAB_FLAG_LIST|TAB_FLAG_SCROLLBACK))
- {
- show_error(ses, LIST_COMMAND, "#SYNTAX: #CURSOR TAB <LIST|SCROLLBACK> FORWARD");
- }
- else
- {
- if (HAS_BIT(flags, TAB_FLAG_LIST|TAB_FLAG_SCROLLBACK) == (TAB_FLAG_LIST|TAB_FLAG_SCROLLBACK))
- {
- cursor_mixed_tab_forward(ses, "");
- }
- else if (HAS_BIT(flags, TAB_FLAG_LIST))
- {
- cursor_tab_forward(ses, "");
- }
- else
- {
- cursor_auto_tab_forward(ses, "");
- }
- }
- SET_BIT(flags, TAB_FLAG_FORWARD);
- }
- else if (is_abbrev(arg1, "BACKWARD"))
- {
- if (!HAS_BIT(flags, TAB_FLAG_LIST|TAB_FLAG_SCROLLBACK))
- {
- show_error(ses, LIST_COMMAND, "#SYNTAX: #CURSOR TAB <LIST|SCROLLBACK> BACKWARD");
- }
- else
- {
- if (HAS_BIT(flags, TAB_FLAG_LIST|TAB_FLAG_SCROLLBACK) == (TAB_FLAG_LIST|TAB_FLAG_SCROLLBACK))
- {
- cursor_mixed_tab_backward(ses, "");
- }
- else if (HAS_BIT(flags, TAB_FLAG_LIST))
- {
- cursor_tab_backward(ses, "");
- }
- else
- {
- cursor_auto_tab_backward(ses, "");
- }
- }
- SET_BIT(flags, TAB_FLAG_BACKWARD);
- }
- else
- {
- show_error(ses, LIST_COMMAND, "#SYNTAX: #CURSOR TAB <LIST|SCROLLBACK> <BACKWARD|FORWARD>");
- }
- }
- DO_CURSOR(cursor_tab_forward)
- {
- struct listroot *root = ses->list[LIST_COMMAND];
- int tab_found;
- if (!root->list[0])
- {
- gtd->input_tab = cursor_calc_input_now();
- }
- if (gtd->input_tab == -1)
- {
- return;
- }
- cursor_hide_completion(gtd->input_tab);
- if (!root->list[0])
- {
- insert_node_list(root, >d->input_buf[gtd->input_tab], "", "", "");
- }
- tab_found = cursor_tab_add(gtd->input_tab, TRUE);
- cursor_show_completion(gtd->input_tab, tab_found);
- }
- DO_CURSOR(cursor_tab_backward)
- {
- struct listroot *root = ses->list[LIST_COMMAND];
- if (!root->list[0])
- {
- gtd->input_tab = cursor_calc_input_now();
- }
- if (gtd->input_tab == -1)
- {
- return;
- }
- cursor_hide_completion(gtd->input_tab);
- if (root->used)
- {
- delete_index_list(root, root->used - 1);
- }
- if (!root->list[0])
- {
- insert_node_list(root, >d->input_buf[gtd->input_tab], "", "", "");
- cursor_tab_add(gtd->input_tab, FALSE);
- }
- cursor_show_completion(gtd->input_tab, TRUE);
- }
- DO_CURSOR(cursor_auto_tab_forward)
- {
- struct listroot *root = ses->list[LIST_COMMAND];
- int tab_found;
- if (!root->list[0])
- {
- gtd->input_tab = cursor_calc_input_now();
- }
- if (gtd->input_tab == -1)
- {
- return;
- }
- cursor_hide_completion(gtd->input_tab);
- if (!root->list[0])
- {
- insert_node_list(root, >d->input_buf[gtd->input_tab], "", "", "");
- }
- tab_found = cursor_auto_tab_add(gtd->input_tab, TRUE);
- cursor_show_completion(gtd->input_tab, tab_found);
- }
- DO_CURSOR(cursor_auto_tab_backward)
- {
- struct listroot *root = ses->list[LIST_COMMAND];
- if (!root->list[0])
- {
- gtd->input_tab = cursor_calc_input_now();
- }
- if (gtd->input_tab == -1)
- {
- return;
- }
- cursor_hide_completion(gtd->input_tab);
- if (root->used)
- {
- delete_index_list(root, root->used - 1);
- }
- if (!root->list[0])
- {
- insert_node_list(root, >d->input_buf[gtd->input_tab], "", "", "");
- cursor_auto_tab_add(gtd->input_tab, FALSE);
- }
- cursor_show_completion(gtd->input_tab, TRUE);
- }
- DO_CURSOR(cursor_mixed_tab_forward)
- {
- struct listroot *root = ses->list[LIST_COMMAND];
- int tab_found;
- if (!root->list[0])
- {
- gtd->input_tab = cursor_calc_input_now();
- }
- if (gtd->input_tab == -1)
- {
- return;
- }
- cursor_hide_completion(gtd->input_tab);
- if (!root->list[0])
- {
- insert_node_list(root, >d->input_buf[gtd->input_tab], "", "", "");
- }
- tab_found = cursor_tab_add(gtd->input_tab, TRUE) || cursor_auto_tab_add(gtd->input_tab, TRUE);
- cursor_show_completion(gtd->input_tab, tab_found);
- }
- DO_CURSOR(cursor_mixed_tab_backward)
- {
- struct listroot *root = ses->list[LIST_COMMAND];
- if (!root->list[0])
- {
- gtd->input_tab = cursor_calc_input_now();
- }
- if (gtd->input_tab == -1)
- {
- return;
- }
- cursor_hide_completion(gtd->input_tab);
- if (root->used)
- {
- delete_index_list(root, root->used - 1);
- }
- if (!root->list[0])
- {
- insert_node_list(root, >d->input_buf[gtd->input_tab], "", "", "");
- cursor_tab_add(gtd->input_tab, FALSE);
- cursor_auto_tab_add(gtd->input_tab, FALSE);
- }
- cursor_show_completion(gtd->input_tab, TRUE);
- }
- DO_CURSOR(cursor_screen_focus_in)
- {
- gtd->screen->focus = 1;
- check_all_events(gtd->ses, SUB_ARG, 0, 1, "SCREEN FOCUS", ntos(gtd->screen->focus));
- msdp_update_all("SCREEN_FOCUS", "%d", gtd->screen->focus);
- }
- DO_CURSOR(cursor_screen_focus_out)
- {
- gtd->screen->focus = 0;
- check_all_events(gtd->ses, SUB_ARG, 0, 1, "SCREEN FOCUS", ntos(gtd->screen->focus));
- msdp_update_all("SCREEN_FOCUS", "%d", gtd->screen->focus);
- }
|