static void WCEL_DeleteRightWord(WCEL_Context* ctx) { unsigned int new_ofs = WCEL_GetRightWordTransition(ctx, ctx->ofs); if (new_ofs != ctx->ofs) { WCEL_DeleteString(ctx, ctx->ofs, new_ofs); } }
static void WCEL_DeletePrevChar(WCEL_Context* ctx) { if (ctx->ofs) { WCEL_DeleteString(ctx, ctx->ofs - 1, ctx->ofs); ctx->ofs--; } }
static void WCEL_KillFromBegOfLine(WCEL_Context* ctx) { if (ctx->ofs) { WCEL_SaveYank(ctx, 0, ctx->ofs); WCEL_DeleteString(ctx, 0, ctx->ofs); ctx->ofs = 0; } }
static void WCEL_KillMarkedZone(WCEL_Context* ctx) { unsigned beg, end; if (ctx->mark > ctx->len || ctx->mark == ctx->ofs) return; if (ctx->mark > ctx->ofs) { beg = ctx->ofs; end = ctx->mark; } else { beg = ctx->mark; end = ctx->ofs; } WCEL_SaveYank(ctx, beg, end); WCEL_DeleteString(ctx, beg, end); ctx->ofs = beg; }
static void WCEL_FindPrevInHist(WCEL_Context* ctx) { int startPos = ctx->histPos; WCHAR* data; unsigned int len, oldofs; if (ctx->histPos && ctx->histPos == ctx->histSize) { startPos--; ctx->histPos--; } do { data = WCEL_GetHistory(ctx, ctx->histPos); if (ctx->histPos) ctx->histPos--; else ctx->histPos = (ctx->histSize-1); len = lstrlenW(data) + 1; if ((len >= ctx->ofs) && (memcmp(ctx->line, data, ctx->ofs * sizeof(WCHAR)) == 0)) { /* need to clean also the screen if new string is shorter than old one */ WCEL_DeleteString(ctx, 0, ctx->len); if (WCEL_Grow(ctx, len)) { oldofs = ctx->ofs; ctx->ofs = 0; WCEL_InsertString(ctx, data); ctx->ofs = oldofs; if (ctx->shall_echo) SetConsoleCursorPosition(ctx->hConOut, WCEL_GetCoord(ctx, ctx->ofs)); HeapFree(GetProcessHeap(), 0, data); return; } } } while (ctx->histPos != startPos); return; }
static void WCEL_MoveToHist(WCEL_Context* ctx, int idx) { WCHAR* data = WCEL_GetHistory(ctx, idx); int len = lstrlenW(data) + 1; /* save current line edition for recall when needed (FIXME seems broken to me) */ if (ctx->histPos == ctx->histSize - 1) { HeapFree(GetProcessHeap(), 0, ctx->histCurr); ctx->histCurr = HeapAlloc(GetProcessHeap(), 0, (ctx->len + 1) * sizeof(WCHAR)); memcpy(ctx->histCurr, ctx->line, (ctx->len + 1) * sizeof(WCHAR)); } /* need to clean also the screen if new string is shorter than old one */ WCEL_DeleteString(ctx, 0, ctx->len); ctx->ofs = 0; /* insert new string */ if (WCEL_Grow(ctx, len)) { WCEL_InsertString(ctx, data); HeapFree(GetProcessHeap(), 0, data); ctx->histPos = idx; } }
static void WCEL_DeleteCurrChar(WCEL_Context* ctx) { if (ctx->ofs < ctx->len) WCEL_DeleteString(ctx, ctx->ofs, ctx->ofs + 1); }
static void WCEL_KillToEndOfLine(WCEL_Context* ctx) { WCEL_SaveYank(ctx, ctx->ofs, ctx->len); WCEL_DeleteString(ctx, ctx->ofs, ctx->len); }