本文整理汇总了C++中refreshLine函数的典型用法代码示例。如果您正苦于以下问题:C++ refreshLine函数的具体用法?C++ refreshLine怎么用?C++ refreshLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了refreshLine函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: linenoiseEditInsert
void linenoiseEditInsert(struct linenoiseState *l, int c)
{
if (l->len < l->buflen) {
if (l->len == l->pos) {
l->buf[l->pos] = c;
l->pos++;
l->len++;
l->buf[l->len] = '\0';
if ((!mlmode && l->plen + l->len < l->cols) /* || mlmode */) {
/* Avoid a full update of the line in the
* trivial case. */
serial.putc(c);
} else {
refreshLine(l);
}
} else {
memmove(l->buf + l->pos + 1, l->buf + l->pos, l->len - l->pos);
l->buf[l->pos] = c;
l->len++;
l->pos++;
l->buf[l->len] = '\0';
refreshLine(l);
}
}
}
开发者ID:ElEHsiang,项目名称:QuadrotorFlightControl,代码行数:28,代码来源:linenoise.c
示例2: linenoiseEditInsert
/* Insert the character 'c' at cursor current position.
*
* On error writing to the terminal -1 is returned, otherwise 0. */
int linenoiseEditInsert(struct linenoiseState *l, char c) {
if (l->len < l->buflen) {
if (l->len == l->pos) {
l->buf[l->pos] = c;
l->pos++;
l->len++;
l->buf[l->len] = '\0';
if ((!mlmode && l->plen+l->len < l->cols) /* || mlmode */) {
/* Avoid a full update of the line in the
* trivial case. */
if (write(l->ofd,&c,1) == -1) return -1;
} else {
refreshLine(l);
}
} else {
memmove(l->buf+l->pos+1,l->buf+l->pos,l->len-l->pos);
l->buf[l->pos] = c;
l->len++;
l->pos++;
l->buf[l->len] = '\0';
refreshLine(l);
}
}
return 0;
}
开发者ID:CORDEA,项目名称:Nim,代码行数:28,代码来源:clinenoise.c
示例3: linenoiseEditInsert
/* Insert the character 'c' at cursor current position.
*
* On error writing to the terminal -1 is returned, otherwise 0. */
int linenoiseEditInsert(struct linenoiseState *l, wchar_t c) {
if (l->len < l->buflen) {
if (l->len == l->pos) {
l->buf[l->pos] = c;
l->pos++;
l->len++;
l->buf[l->len] = L'\0';
if ((!mlmode && l->plen+l->len < l->cols) /* || mlmode */) {
/* Avoid a full update of the line in the
* trivial case. */
console_write_wchar_string(&c, 1);
} else {
refreshLine(l);
}
} else {
memmove(l->buf+l->pos+1, l->buf+l->pos, sizeof(wchar_t) * (l->len-l->pos));
l->buf[l->pos] = c;
l->len++;
l->pos++;
l->buf[l->len] = L'\0';
refreshLine(l);
}
}
return 0;
}
开发者ID:bossjones,项目名称:burro-engine,代码行数:28,代码来源:lineedit.cpp
示例4: completeLine
/* This is an helper function for linenoiseEdit() and is called when the
* user types the <tab> key in order to complete the string currently in the
* input.
*
* The state of the editing is encapsulated into the pointed linenoiseState
* structure as described in the structure definition. */
static int completeLine(struct linenoiseState *ls) {
linenoiseCompletions lc = { 0, NULL };
int nread, nwritten;
char c = 0;
completionCallback(ls->buf,&lc);
if (lc.len == 0) {
linenoiseBeep();
} else {
size_t stop = 0, i = 0;
while(!stop) {
/* Show completion or original buffer */
if (i < lc.len) {
struct linenoiseState saved = *ls;
ls->len = ls->pos = strlen(lc.cvec[i]);
ls->buf = lc.cvec[i];
refreshLine(ls);
ls->len = saved.len;
ls->pos = saved.pos;
ls->buf = saved.buf;
} else {
refreshLine(ls);
}
nread = read(ls->ifd,&c,1);
if (nread <= 0) {
freeCompletions(&lc);
return -1;
}
switch(c) {
case 9: /* tab */
i = (i+1) % (lc.len+1);
if (i == lc.len) linenoiseBeep();
break;
case 27: /* escape */
/* Re-show original buffer */
if (i < lc.len) refreshLine(ls);
stop = 1;
break;
default:
/* Update buffer and return */
if (i < lc.len) {
nwritten = snprintf(ls->buf,ls->buflen,"%s",lc.cvec[i]);
ls->len = ls->pos = nwritten;
}
stop = 1;
break;
}
}
}
freeCompletions(&lc);
return c; /* Return last read character */
}
开发者ID:CORDEA,项目名称:Nim,代码行数:63,代码来源:clinenoise.c
示例5: completeLine
static int completeLine(int fd, const char *prompt, char *buf, size_t buflen, size_t *len, size_t *pos, size_t cols) {
linenoiseCompletions lc = { 0, NULL };
int nwritten;
char c = 0;
completionCallback(buf,&lc);
if (lc.len == 0) {
beep();
} else {
size_t stop = 0, i = 0;
size_t clen;
while(!stop) {
/* Show completion or original buffer */
if (i < lc.len) {
clen = strlen(lc.cvec[i]);
refreshLine(fd,prompt,lc.cvec[i],clen,clen,cols);
} else {
refreshLine(fd,prompt,buf,*len,*pos,cols);
}
do {
c = linenoiseReadChar(fd);
} while (c == (char)-1);
switch(c) {
case 0:
freeCompletions(&lc);
return -1;
case 9: /* tab */
i = (i+1) % (lc.len+1);
if (i == lc.len) beep();
break;
case 27: /* escape */
/* Re-show original buffer */
if (i < lc.len) {
refreshLine(fd,prompt,buf,*len,*pos,cols);
}
stop = 1;
break;
default:
/* Update buffer and return */
if (i < lc.len) {
nwritten = snprintf(buf,buflen,"%s",lc.cvec[i]);
*len = *pos = nwritten;
}
stop = 1;
break;
}
}
}
freeCompletions(&lc);
return c; /* Return last read character */
}
开发者ID:DumaGit,项目名称:mongo,代码行数:55,代码来源:linenoise.cpp
示例6: completeLine
static int completeLine(struct current *current) {
linenoiseCompletions lc = { 0, NULL };
int c = 0;
completionCallback(current->buf,&lc,completionUserdata);
if (lc.len == 0) {
beep();
} else {
size_t stop = 0, i = 0;
while(!stop) {
/* Show completion or original buffer */
if (i < lc.len) {
struct current tmp = *current;
tmp.buf = lc.cvec[i];
tmp.pos = tmp.len = strlen(tmp.buf);
tmp.chars = utf8_strlen(tmp.buf, tmp.len);
refreshLine(current->prompt, &tmp);
} else {
refreshLine(current->prompt, current);
}
c = fd_read(current);
if (c == -1) {
break;
}
switch(c) {
case '\t': /* tab */
i = (i+1) % (lc.len+1);
if (i == lc.len) beep();
break;
case 27: /* escape */
/* Re-show original buffer */
if (i < lc.len) {
refreshLine(current->prompt, current);
}
stop = 1;
break;
default:
/* Update buffer and return */
if (i < lc.len) {
set_current(current,lc.cvec[i]);
}
stop = 1;
break;
}
}
}
freeCompletions(&lc);
return c; /* Return last read character */
}
开发者ID:evanhunter,项目名称:jimtcl,代码行数:53,代码来源:linenoise.c
示例7: linenoiseEditHistoryNext
void linenoiseEditHistoryNext(struct linenoiseState *l, int dir)
{
if (history_len > 1) {
/* Update the current history entry before to
* overwrite it with the next one. */
free(history[history_len - 1 - l->history_index]);
history[history_len - 1 - l->history_index] = strdup(l->buf);
/* Show the new entry */
l->history_index += (dir == LINENOISE_HISTORY_PREV) ? 1 : -1;
if (l->history_index < 0) {
l->history_index = 0;
return;
} else if (l->history_index >= history_len) {
l->history_index = history_len - 1;
return;
}
strncpy(l->buf, history[history_len - 1 - l->history_index], l->buflen);
l->buf[l->buflen - 1] = '\0';
l->len = l->pos = strlen(l->buf);
refreshLine(l);
}
}
开发者ID:ElEHsiang,项目名称:QuadrotorFlightControl,代码行数:25,代码来源:linenoise.c
示例8: lineedit_start
void lineedit_start(wchar_t *buf, size_t buflen, const wchar_t *prompt)
{
memset(&l, 0, sizeof(l));
/* Populate the linenoise state that we pass to functions implementing
* specific editing functionalities. */
l.buf = buf;
l.buflen = buflen;
l.prompt = prompt;
l.plen = wcslen(prompt);
l.oldpos = l.pos = 0;
l.len = 0;
l.cols = CONSOLE_COLS;
l.maxrows = 0;
l.history_index = 0;
/* Buffer starts empty. */
l.buf[0] = L'\0';
l.buflen--; /* Make sure there is always space for the nulterm */
/* The latest history entry is always our current buffer, that
* initially is just an empty string. */
linenoiseHistoryAdd(L"");
refreshLine(&l);
}
开发者ID:bossjones,项目名称:burro-engine,代码行数:25,代码来源:lineedit.cpp
示例9: linenoiseEditMoveLeft
void linenoiseEditMoveLeft(struct linenoiseState *l)
{
if (l->pos > 0) {
l->pos--;
refreshLine(l);
}
}
开发者ID:ElEHsiang,项目名称:QuadrotorFlightControl,代码行数:7,代码来源:linenoise.c
示例10: linenoiseEditMoveRight
void linenoiseEditMoveRight(struct linenoiseState *l)
{
if (l->pos != l->len) {
l->pos++;
refreshLine(l);
}
}
开发者ID:ElEHsiang,项目名称:QuadrotorFlightControl,代码行数:7,代码来源:linenoise.c
示例11: completeLine
static retCode completeLine(LineState *ls) {
integer cx = 0;
strgPo snapShot = stringFromBuffer(ls->lineBuff);
integer snapPos = bufferOutPos(ls->lineBuff);
do {
retCode ret = completionCallback(ls->lineBuff, completionCl, cx++);
switch (ret) {
case Ok: {
char ch;
if (rawInChar(&ch) != Ok) {
resetBuffer(ls->lineBuff, snapShot, snapPos);
decReference(O_OBJECT(snapShot));
return Error;
} else {
switch (ch) {
case TAB:
resetBuffer(ls->lineBuff, snapShot, snapPos);
continue;
case ESC:
resetBuffer(ls->lineBuff, snapShot, snapPos);
decReference(O_OBJECT(snapShot));
refreshLine(ls->firstPos, ls->lineBuff);
return Ok;
case SPACE:
case ENTER:
decReference(O_OBJECT(snapShot));
return Ok;
default:
beep();
continue;
}
}
}
case Eof:
resetBuffer(ls->lineBuff, snapShot, snapPos);
decReference(O_OBJECT(snapShot));
refreshLine(ls->firstPos, ls->lineBuff);
return Ok;
default:
case Error:
return Error;
}
} while (True);
}
开发者ID:fmccabe,项目名称:cafe,代码行数:47,代码来源:editline.c
示例12: linenoiseEditDelete
/* Delete the character at the right of the cursor without altering the cursor
* position. Basically this is what happens with the "Delete" keyboard key. */
void linenoiseEditDelete(struct linenoiseState *l) {
if (l->len > 0 && l->pos < l->len) {
memmove(l->buf+l->pos,l->buf+l->pos+1,l->len-l->pos-1);
l->len--;
l->buf[l->len] = '\0';
refreshLine(l);
}
}
开发者ID:CORDEA,项目名称:Nim,代码行数:10,代码来源:clinenoise.c
示例13: linenoiseSetPrompt
void linenoiseSetPrompt(const char *p){
_current->prompt = p;
refreshLine(p, _current);
/* Cursor to left edge, then the prompt */
cursorToLeft(_current);
outputChars(_current, p, 4);
//printf("%s", "hej");
// fflush(stdout);
}
开发者ID:hscarter,项目名称:revbayes,代码行数:9,代码来源:linenoise.c
示例14: linenoiseEditBackspace
/* Backspace implementation. */
void linenoiseEditBackspace(struct linenoiseState *l) {
if (l->pos > 0 && l->len > 0) {
memmove(l->buf+l->pos-1,l->buf+l->pos,l->len-l->pos);
l->pos--;
l->len--;
l->buf[l->len] = '\0';
refreshLine(l);
}
}
开发者ID:CORDEA,项目名称:Nim,代码行数:10,代码来源:clinenoise.c
示例15: scrollPageUp
//////////////////////////////////////////////////////////////////////
// Function Name:
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CListFrame::scrollLineUp(const int lines)
{
//TRACE("[CListFrame]->scrollLineUp \r\n");
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return;
if(m_nSelectedLine > 0) m_nSelectedLine--;
// check if the cursor moves out of the window
if(m_nSelectedLine < m_nCurrentLine )
{
// yes, scroll to next page
//TRACE("[CListFrame] m_nSelectedLine: %d, \r\n",m_nSelectedLine);
scrollPageUp(1);
}
else
{
refreshLine(m_nSelectedLine+lines);
refreshLine(m_nSelectedLine);
}
}
开发者ID:ChakaZulu,项目名称:tuxbox_apps,代码行数:28,代码来源:listframe.cpp
示例16: moveInHistory
void moveInHistory(LineState *l, historyDir dir) {
if (vectLength(history) > 0) {
l->history_index = clamp(0, l->history_index + dir, vectLength(history) - 1);
strgPo entry = O_STRG(getVectEl(history, l->history_index));
clearBuffer(l->lineBuff);
stringIntoBuffer(l->lineBuff, entry);
refreshLine(l->firstPos, l->lineBuff);
}
}
开发者ID:fmccabe,项目名称:cafe,代码行数:11,代码来源:editline.c
示例17: linenoiseEditOverwrite
int linenoiseEditOverwrite(struct linenoiseState *l, wchar_t c) {
if (l->len < l->buflen) {
if (l->len == l->pos) {
l->buf[l->pos] = c;
l->pos++;
l->len++;
l->buf[l->len] = L'\0';
if (!mlmode && (l->plen + l->len < l->cols)) {
console_write_wchar_string(&c, 1);
} else {
refreshLine(l);
}
} else {
l->buf[l->pos] = c;
l->pos ++;
refreshLine(l);
}
}
return 0;
}
开发者ID:bossjones,项目名称:burro-engine,代码行数:20,代码来源:lineedit.cpp
示例18: lineedit_swap_chars
void lineedit_swap_chars()
{
if (l.pos > 0 && l.pos < l.len) {
wchar_t aux = l.buf[l.pos-1];
l.buf[l.pos-1] = l.buf[l.pos];
l.buf[l.pos] = aux;
if (l.pos != l.len-1)
l.pos ++;
refreshLine(&l);
}
}
开发者ID:bossjones,项目名称:burro-engine,代码行数:11,代码来源:lineedit.cpp
示例19: linenoiseEditDeletePrevWord
/* Delete the previosu word, maintaining the cursor at the start of the
* current word. */
void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
size_t old_pos = l->pos;
size_t diff;
while (l->pos > 0 && l->buf[l->pos-1] == ' ')
l->pos--;
while (l->pos > 0 && l->buf[l->pos-1] != ' ')
l->pos--;
diff = old_pos - l->pos;
memmove(l->buf+l->pos,l->buf+old_pos,l->len-old_pos+1);
l->len -= diff;
refreshLine(l);
}
开发者ID:CORDEA,项目名称:Nim,代码行数:15,代码来源:clinenoise.c
示例20: scrollPageDown
//////////////////////////////////////////////////////////////////////
// Function Name:
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CListFrame::scrollLineDown(const int lines)
{
//TRACE("[CListFrame]->scrollLineDown \r\n");
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return;
if(m_nSelectedLine < m_nNrOfLines - 1 && m_nNrOfLines != 0) m_nSelectedLine++;
// check if the cursor moves out of the window
if(m_nSelectedLine - m_nCurrentLine > m_nLinesPerPage-1)
{
// yes, scroll to next page
//TRACE("[CListFrame] m_nSelectedLine: %d, \r\n",m_nSelectedLine);
scrollPageDown(1);
}
else
{
refreshLine(m_nSelectedLine-lines);
refreshLine(m_nSelectedLine);
}
}
开发者ID:ChakaZulu,项目名称:tuxbox_apps,代码行数:30,代码来源:listframe.cpp
注:本文中的refreshLine函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论