int slk_set(int labnum, const char *label, int justify) { #ifdef PDC_WIDE wchar_t wlabel[32]; PDC_mbstowcs(wlabel, label, 31); return slk_wset(labnum, wlabel, justify); #else PDC_LOG(("slk_set() - called\n")); if (labnum < 1 || labnum > labels || justify < 0 || justify > 2) return ERR; labnum--; if (!label || !(*label)) { /* Clear the label */ *slk[labnum].label = 0; slk[labnum].format = 0; slk[labnum].len = 0; } else { int i, j = 0; /* Skip leading spaces */ while (label[j] == ' ') j++; /* Copy it */ for (i = 0; i < label_length; i++) { chtype ch = label[i + j]; slk[labnum].label[i] = ch; if (!ch) break; } /* Drop trailing spaces */ while ((i + j) && (label[i + j - 1] == ' ')) i--; slk[labnum].label[i] = 0; slk[labnum].format = justify; slk[labnum].len = i; } _drawone(labnum); return OK; #endif }
int slk_set(int labnum, const char *label, int justify) { #ifdef PDC_WIDE wchar_t wlabel[MAX_LABEL_LENGTH]; PDC_mbstowcs(wlabel, label, MAX_LABEL_LENGTH - 1); return slk_wset(labnum, wlabel, justify); #else PDC_LOG(("slk_set() - called\n")); if (labnum < 1 || labnum > n_labels || justify < 0 || justify > 2) return ERR; labnum--; if (!label || !(*label)) { /* Clear the label */ *slk[labnum].label = 0; slk[labnum].format = 0; slk[labnum].len = 0; } else { int i; /* Skip leading spaces */ while( *label == ' ') label++; /* Copy it */ for (i = 0; label[i] && i < MAX_LABEL_LENGTH - 1; i++) slk[labnum].label[i] = label[i]; /* Drop trailing spaces */ while( i && label[i - 1] == ' ') i--; slk[labnum].label[i] = 0; slk[labnum].format = justify; slk[labnum].len = i; } _drawone(labnum); return OK; #endif }
void PDC_set_title(const char *title) { #ifdef PDC_WIDE wchar_t wtitle[512]; #endif PDC_LOG(("PDC_set_title() - called:<%s>\n", title)); #ifdef PDC_WIDE PDC_mbstowcs(wtitle, title, 511); SetConsoleTitleW(wtitle); #else SetConsoleTitleA(title); #endif }
int PDC_setclipboard(const char *contents, long length) { #ifdef PDC_WIDE wchar_t *wcontents; #endif int rc; PDC_LOG(("PDC_setclipboard() - called\n")); #ifdef PDC_WIDE wcontents = malloc((length + 1) * sizeof(wchar_t)); if (!wcontents) return PDC_CLIP_MEMORY_ERROR; length = PDC_mbstowcs(wcontents, contents, length); #endif XCursesInstruct(CURSES_SET_SELECTION); /* Write, then wait for X to do its stuff; expect return code. */ if (XC_write_socket(xc_display_sock, &length, sizeof(long)) >= 0) { if (XC_write_socket(xc_display_sock, #ifdef PDC_WIDE wcontents, length * sizeof(wchar_t)) >= 0) { free(wcontents); #else contents, length) >= 0) { #endif if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0) return rc; } } XCursesExitCursesProcess(5, "exiting from PDC_setclipboard"); return PDC_CLIP_ACCESS_ERROR; /* not reached */ }
int PDC_setclipboard(const char *contents, long length) { HGLOBAL ptr1; LPTSTR ptr2; PDC_LOG(("PDC_setclipboard() - called\n")); if (!OpenClipboard(NULL)) return PDC_CLIP_ACCESS_ERROR; ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, (length + 1) * sizeof(TCHAR)); if (!ptr1) return PDC_CLIP_MEMORY_ERROR; ptr2 = (LPTSTR)GlobalLock(ptr1); #ifdef PDC_WIDE PDC_mbstowcs((wchar_t *)ptr2, contents, length); #else memcpy((char *)ptr2, contents, length + 1); #endif GlobalUnlock(ptr1); EmptyClipboard(); if (!SetClipboardData(PDC_TEXT, ptr1)) { GlobalFree(ptr1); return PDC_CLIP_ACCESS_ERROR; } CloseClipboard(); GlobalFree(ptr1); return PDC_CLIP_SUCCESS; }