Commit 14585ba2 authored by rswindell's avatar rswindell
Browse files

Added support for "Cut" operations in uifc.list() - must be called with WIN_GET

- returns index with MSK_CUT in upper nibble
- Cut is initiated with Ctrl-X or Shif-Delete
- Same as Get/Copy (F6/Ctrl-V) except the source item is removed

* Ctrl-Insert is now supported for Copy (in addition to Ctrl-C and F5)
* Shift-Insert is now supported for Paste (in addition to Ctrl-V and F6)

* Fixed a couple of potential NULL savbuf dereferences (one sighted when using
mouse).
parent 3733f04f
......@@ -101,9 +101,15 @@
#define MSK_OFF 0x0fffffff
#define MSK_INS 0x10000000
#define MSK_DEL 0x20000000
#define MSK_GET 0x30000000
#define MSK_PUT 0x40000000
#define MSK_EDIT 0x50000000
#define MSK_COPY 0x30000000
#define MSK_CUT 0x40000000
#define MSK_PASTE 0x50000000
#define MSK_EDIT 0x60000000
/* Legacy terms (get/put instead of copy/paste) */
#define MSK_GET MSK_COPY
#define MSK_PUT MSK_PASTE
/* Don't forget, negative return values are used for extended keys (if WIN_EXTKEYS used)! */
#define MAX_OPLN 75 /* Maximum length of each option per menu call */
#define MAX_BUFS 7 /* Maximum number of screen buffers to save */
......@@ -124,7 +130,7 @@
#define UIFC_MONO (1<<2) /* Force monochrome mode */
#define UIFC_COLOR (1<<3) /* Force color mode */
#define UIFC_IBM (1<<4) /* Force use of IBM charset */
#define UIFC_NOCTRL (1<<5) /* Don't allow useage of CTRL keys for movement
#define UIFC_NOCTRL (1<<5) /* Don't allow usage of CTRL keys for movement
* etc in menus (Still available in text boxes) */
#define UIFC_NHM (1<<6) /* Don't hide the mouse pointer */
......
......@@ -1161,9 +1161,10 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
api->savnum--;
if(!(api->mode&UIFC_NHM))
uifc_mouse_disable();
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if(sav[api->savnum].buf != NULL)
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if(!(api->mode&UIFC_NHM))
uifc_mouse_enable();
FREE_AND_NULL(sav[api->savnum].buf);
......@@ -1237,6 +1238,10 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
if(!(api->mode&UIFC_NOCTRL))
gotkey=CIO_KEY_F(5); /* copy */
break;
case CTRL_X:
if(!(api->mode&UIFC_NOCTRL))
gotkey=CIO_KEY_SHIFT_DC; /* cut */
break;
case CTRL_V:
if(!(api->mode&UIFC_NOCTRL))
gotkey=CIO_KEY_F(6); /* paste */
......@@ -1568,19 +1573,26 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
}
else if(mode&WIN_SAV) {
api->savnum--;
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if(sav[api->savnum].buf != NULL)
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
FREE_AND_NULL(sav[api->savnum].buf);
}
return((*cur)|MSK_EDIT);
}
break;
case CIO_KEY_F(5): /* F5 - Copy */
case CIO_KEY_F(5): /* F5 - Copy */
case CIO_KEY_CTRL_IC: /* Ctrl-Insert */
if(mode&WIN_GET && !(mode&WIN_XTR && (*cur)==opts-1))
return((*cur)|MSK_GET);
break;
case CIO_KEY_F(6): /* F6 - Paste */
case CIO_KEY_SHIFT_DC: /* Shift-Del: Cut */
if(mode&WIN_GET && !(mode&WIN_XTR && (*cur) == opts - 1))
return((*cur) | MSK_CUT);
break;
case CIO_KEY_F(6): /* F6 - Paste */
case CIO_KEY_SHIFT_IC: /* Shift-Insert */
if(mode&WIN_PUT && (mode&WIN_PUTXTR || !(mode&WIN_XTR && (*cur)==opts-1)))
return((*cur)|MSK_PUT);
break;
......@@ -1602,9 +1614,10 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
}
else if(mode&WIN_SAV) {
api->savnum--;
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if(sav[api->savnum].buf != NULL)
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
FREE_AND_NULL(sav[api->savnum].buf);
}
if(!opts) {
......@@ -1633,9 +1646,10 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
}
else if(mode&WIN_SAV) {
api->savnum--;
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if (sav[api->savnum].buf != NULL)
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
FREE_AND_NULL(sav[api->savnum].buf);
}
return((*cur)|MSK_DEL);
......@@ -1763,9 +1777,10 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
}
else if(mode&WIN_SAV) {
api->savnum--;
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if (sav[api->savnum].buf != NULL)
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
FREE_AND_NULL(sav[api->savnum].buf);
}
if(mode&WIN_XTR && (*cur)==opts-1)
......@@ -1785,9 +1800,10 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
}
else if(mode&WIN_SAV) {
api->savnum--;
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
if (sav[api->savnum].buf != NULL)
puttext(sav[api->savnum].left,sav[api->savnum].top
,sav[api->savnum].right,sav[api->savnum].bot
,sav[api->savnum].buf);
FREE_AND_NULL(sav[api->savnum].buf);
}
return(-1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment