mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
add an append operation to cut buffer handling
This commit is contained in:
parent
dc03baa0d3
commit
876609901a
@ -582,13 +582,29 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size, CUTBUFFER_UPDATE_OP update_
|
|||||||
if (size == 0 || entry->pos < size)
|
if (size == 0 || entry->pos < size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (update_cutbuffer) {
|
if (entry->cutbuffer_len == 0) {
|
||||||
case CUTBUFFER_UPDATE_PREPEND:
|
update_cutbuffer = CUTBUFFER_UPDATE_REPLACE;
|
||||||
if (entry->cutbuffer_len) {
|
}
|
||||||
int cutbuffer_new_size = entry->cutbuffer_len + size;
|
int cutbuffer_new_size = entry->cutbuffer_len + size;
|
||||||
unichar *tmpcutbuffer = entry->cutbuffer;
|
unichar *tmpcutbuffer = entry->cutbuffer;
|
||||||
|
switch (update_cutbuffer) {
|
||||||
|
case CUTBUFFER_UPDATE_APPEND:
|
||||||
entry->cutbuffer = g_new(unichar, cutbuffer_new_size+1);
|
entry->cutbuffer = g_new(unichar, cutbuffer_new_size+1);
|
||||||
|
if (entry->cutbuffer) {
|
||||||
|
memcpy(entry->cutbuffer, tmpcutbuffer,
|
||||||
|
entry->cutbuffer_len * sizeof(unichar));
|
||||||
|
memcpy(entry->cutbuffer + entry->cutbuffer_len * sizeof(unichar),
|
||||||
|
entry->text + entry->pos - size, size * sizeof(unichar));
|
||||||
|
|
||||||
|
entry->cutbuffer_len = cutbuffer_new_size;
|
||||||
|
entry->cutbuffer[cutbuffer_new_size] = '\0';
|
||||||
|
g_free(tmpcutbuffer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CUTBUFFER_UPDATE_PREPEND:
|
||||||
|
entry->cutbuffer = g_new(unichar, cutbuffer_new_size+1);
|
||||||
|
if (entry->cutbuffer) {
|
||||||
memcpy(entry->cutbuffer, entry->text + entry->pos - size,
|
memcpy(entry->cutbuffer, entry->text + entry->pos - size,
|
||||||
size * sizeof(unichar));
|
size * sizeof(unichar));
|
||||||
memcpy(entry->cutbuffer + size, tmpcutbuffer,
|
memcpy(entry->cutbuffer + size, tmpcutbuffer,
|
||||||
@ -596,11 +612,10 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size, CUTBUFFER_UPDATE_OP update_
|
|||||||
|
|
||||||
entry->cutbuffer_len = cutbuffer_new_size;
|
entry->cutbuffer_len = cutbuffer_new_size;
|
||||||
entry->cutbuffer[cutbuffer_new_size] = '\0';
|
entry->cutbuffer[cutbuffer_new_size] = '\0';
|
||||||
|
|
||||||
g_free(tmpcutbuffer);
|
g_free(tmpcutbuffer);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* fall through to REPLACE if cutbuffer_len was 0 */
|
break;
|
||||||
|
|
||||||
case CUTBUFFER_UPDATE_REPLACE:
|
case CUTBUFFER_UPDATE_REPLACE:
|
||||||
/* put erased text to cutbuffer */
|
/* put erased text to cutbuffer */
|
||||||
if (entry->cutbuffer_len < size) {
|
if (entry->cutbuffer_len < size) {
|
||||||
@ -613,6 +628,7 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size, CUTBUFFER_UPDATE_OP update_
|
|||||||
memcpy(entry->cutbuffer, entry->text + entry->pos - size,
|
memcpy(entry->cutbuffer, entry->text + entry->pos - size,
|
||||||
size * sizeof(unichar));
|
size * sizeof(unichar));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CUTBUFFER_UPDATE_NOOP:
|
case CUTBUFFER_UPDATE_NOOP:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ typedef struct {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
CUTBUFFER_UPDATE_NOOP,
|
CUTBUFFER_UPDATE_NOOP,
|
||||||
CUTBUFFER_UPDATE_REPLACE,
|
CUTBUFFER_UPDATE_REPLACE,
|
||||||
|
CUTBUFFER_UPDATE_APPEND,
|
||||||
CUTBUFFER_UPDATE_PREPEND
|
CUTBUFFER_UPDATE_PREPEND
|
||||||
} CUTBUFFER_UPDATE_OP;
|
} CUTBUFFER_UPDATE_OP;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user