1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Eat right character. Copy the command line to the history buffer.
11
(1) Pointer to RuntimeS structure.
14
(1) One character removed.
18
(1) Positive on success.
19
(2) Negative on failure.
21
========includes:============================================================*/
28
#include <X11/Xutil.h>
30
#include <X11/Xatom.h>
35
/*======eat right character:=================================================*/
37
int EatRightChar_ (RuntimeS *runtimeSP)
39
int comm_length, old_comm_length, carriage_pos;
40
char stringA[COMMSTRINGSIZE];
43
/* Copy the command string length and carriage (keyboard cursor) position: */
44
comm_length = runtimeSP->command_length;
45
old_comm_length = comm_length;
46
carriage_pos = runtimeSP->carriage_position;
48
/* Check is there anything on the right side: */
49
if (carriage_pos >= comm_length) return -1;
51
/* Reduce the command length: */
54
/* Copy the left part: */
55
strncpy (stringA, runtimeSP->curr_commandA, carriage_pos);
56
stringA[carriage_pos] = '\0';
58
/* Copy the right part, but skip the first character: */
60
runtimeSP->curr_commandA + carriage_pos + 1,
61
old_comm_length - carriage_pos - 1);
63
/* Ensure the proper termination: */
64
stringA[comm_length] = '\0';
66
/* Copy the command string: */
67
strcpy (runtimeSP->curr_commandA, stringA);
69
/* Set the command length: */
70
runtimeSP->command_length = comm_length;
72
/* Copy the command string to the output buffer: */
73
currP = runtimeSP->commandsP + runtimeSP->curr_commandI * COMMSTRINGSIZE;
74
strcpy (currP, runtimeSP->curr_commandA);
76
/* Return positive value (success): */
80
/*===========================================================================*/