Git Product home page Git Product logo

pdcurses's People

Contributors

adoxa avatar aiafrasinei avatar alexanderkjackson avatar astralchan avatar bill-gray avatar bitterlyironic avatar cdfrey avatar chasonr avatar elyesh avatar flrl avatar giorgosxou avatar gitmensch avatar kklobe avatar mannyamorim avatar pgeorgi avatar raphnet avatar reinauer avatar rgson avatar savalione avatar techtonik avatar thentenaar avatar turkeymcmac avatar uhlin avatar vyv03354 avatar wmcbrine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdcurses's Issues

ncurses compatibility: allow newwin off-screen

This came up in #57 first, as it is a completely different issue with some effort to put in it is tracked here.

Initial finding of @tysenmoore-xse, documented in his repo:

... better handle windows that are out of the screen size. PDCurses will not allocate the window [...] ncurses appears to allocate the window just fine.

@wmcbrine commented:

Yeah, I noticed the oversized window thing a while back. I was actually surprised that ncurses does that, but, emulating it is probably the right thing.
and:
Clipping is not contemplated. Working like ncurses means returning the requested size, even if parts of it are off-screen.

with the additional notes of @Bill-Gray:

[...] newwin could do no clipping nor checking, and would allocate the entire window; it's just that there would be parts of that window you couldn't see (unless the window was moved). That would require a fair bit of change elsewhere, I think, inasmuch as we'd have to have logic that said : 'use this part of the window, but only the parts that actually land on the screen." At present, you can move windows, but you can't move parts of them off-screen.
and:
I just did some experimenting with newwin in ncurses, and found that it does have that limitation. You can call newwin with the x and y coordinates for the upper left corner to put the window partly off-screen to the right or bottom, but negative values for x or y fail.
I'd argue that ncurses has it wrong. If you're going to allow windows to go off the right or bottom edge, then the top and left edges should be fair game.

getch - timeout resolution with undocumented artificial min

https://github.com/wmcbrine/PDCurses/blob/master/pdcurses/getch.c#L181 has:

            /* Can't really do millisecond intervals, so delay in
               1/20ths of a second (50ms) */

But I see no reason for this "cannot". Is this some ancient issue (the code was last changed 14 years ago 9645721 providing a finer resolution from 10th to 20th of a second)?

The current version would be at least a documentation issue as https://github.com/wmcbrine/PDCurses/blob/master/man/MANUAL.md#L1358 doesn't say that there's a jump from 0 to 50 and all that's in between means 50.

To test I've run a check:

  • loop over var increasing timeout from 0ms up to 999
  • get system time, call timeout, getch, get system time, calculate diff, show loop counter and timediff

result with ncurses on Win32: 0-999, nearly always matching timeout->calculated
PDCurses: 0,~50 until 50, then increasing as expected.

Suggestion: either drop the artificial lower limit completely or set it down from 50ms to 5ms and document it.

wincon cursor appears even when opposite is set

after the initscr(), i properly set the curs_set(0), but it seems like it doesn't work for another window. is it an expected behavior?

see screenshot:
image
here, the blinking cursor after M is the cursor of a window created after the curs_set

Possibly missing 'SP->key_code = TRUE' setting for KEY_RESIZE in wincon

"Possibly" because I haven't actually tried it out, but it looks like it might be the cause of some behavior I'm seeing, and I don't see it getting set for KEY_RESIZE in wincon/pdckbd.c. :)

I'm using the Python wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses (provided by @cgohlke), which use PDCurses as their backend.

The issue is that get_wch() in Python returns KEY_RESIZE as a string rather than as an integer when using PDCurses. Looking at the code at https://github.com/python/cpython/blob/master/Modules/_cursesmodule.c#L1222, it probably means that get_wch() doesn't return KEY_CODE_YES for it.

Win 10 makefile

Hello.
I tried to run makefile with mingw32-make and it gave me this error message.

C:\Windows\system32>cd C:\pdcurs35\win32

C:\pdcurs35\win32>mingw32-make -f gccwin32.mak
gcc -c -O2 -Wall -I.. ../pdcurses/addch.c
gcc -c -O2 -Wall -I.. ../pdcurses/addchstr.c
gcc -c -O2 -Wall -I.. ../pdcurses/addstr.c
gcc -c -O2 -Wall -I.. ../pdcurses/attr.c
gcc -c -O2 -Wall -I.. ../pdcurses/beep.c
gcc -c -O2 -Wall -I.. ../pdcurses/bkgd.c
gcc -c -O2 -Wall -I.. ../pdcurses/border.c
gcc -c -O2 -Wall -I.. ../pdcurses/clear.c
gcc -c -O2 -Wall -I.. ../pdcurses/color.c
gcc -c -O2 -Wall -I.. ../pdcurses/delch.c
gcc -c -O2 -Wall -I.. ../pdcurses/deleteln.c
gcc -c -O2 -Wall -I.. ../pdcurses/deprec.c
gcc -c -O2 -Wall -I.. ../pdcurses/getch.c
gcc -c -O2 -Wall -I.. ../pdcurses/getstr.c
gcc -c -O2 -Wall -I.. ../pdcurses/getyx.c
gcc -c -O2 -Wall -I.. ../pdcurses/inch.c
gcc -c -O2 -Wall -I.. ../pdcurses/inchstr.c
gcc -c -O2 -Wall -I.. ../pdcurses/initscr.c
gcc -c -O2 -Wall -I.. ../pdcurses/inopts.c
gcc -c -O2 -Wall -I.. ../pdcurses/insch.c
gcc -c -O2 -Wall -I.. ../pdcurses/insstr.c
gcc -c -O2 -Wall -I.. ../pdcurses/instr.c
gcc -c -O2 -Wall -I.. ../pdcurses/kernel.c
gcc -c -O2 -Wall -I.. ../pdcurses/keyname.c
gcc -c -O2 -Wall -I.. ../pdcurses/mouse.c
gcc -c -O2 -Wall -I.. ../pdcurses/move.c
gcc -c -O2 -Wall -I.. ../pdcurses/outopts.c
gcc -c -O2 -Wall -I.. ../pdcurses/overlay.c
gcc -c -O2 -Wall -I.. ../pdcurses/pad.c
gcc -c -O2 -Wall -I.. ../pdcurses/panel.c
gcc -c -O2 -Wall -I.. ../pdcurses/printw.c
gcc -c -O2 -Wall -I.. ../pdcurses/refresh.c
gcc -c -O2 -Wall -I.. ../pdcurses/scanw.c
gcc -c -O2 -Wall -I.. ../pdcurses/scr_dump.c
gcc -c -O2 -Wall -I.. ../pdcurses/scroll.c
gcc -c -O2 -Wall -I.. ../pdcurses/slk.c
gcc -c -O2 -Wall -I.. ../pdcurses/termattr.c
gcc -c -O2 -Wall -I.. ../pdcurses/terminfo.c
gcc -c -O2 -Wall -I.. ../pdcurses/touch.c
gcc -c -O2 -Wall -I.. ../pdcurses/util.c
gcc -c -O2 -Wall -I.. ../pdcurses/window.c
gcc -c -O2 -Wall -I.. ../pdcurses/debug.c
gcc -c -O2 -Wall -I.. ../win32/pdcclip.c
gcc -c -O2 -Wall -I.. ../win32/pdcdisp.c
gcc -c -O2 -Wall -I.. ../win32/pdcgetsc.c
gcc -c -O2 -Wall -I.. ../win32/pdckbd.c
gcc -c -O2 -Wall -I.. ../win32/pdcscrn.c
../win32/pdcscrn.c:69:5: error: unknown type name 'PCONSOLE_SCREEN_BUFFER_INFOEX'
PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:71:5: error: unknown type name 'PCONSOLE_SCREEN_BUFFER_INFOEX'
PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:73:8: error: unknown type name 'SetConsoleScreenBufferInfoExFn'
static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:73:71: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
^~~~
../win32/pdcscrn.c:74:8: error: unknown type name 'GetConsoleScreenBufferInfoExFn'
static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:74:71: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL;
^~~~
../win32/pdcscrn.c:77:8: error: unknown type name 'CONSOLE_SCREEN_BUFFER_INFOEX'
static CONSOLE_SCREEN_BUFFER_INFOEX console_infoex;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c: In function '_set_console_infoex':
../win32/pdcscrn.c:172:10: error: called object 'pSetConsoleScreenBufferInfoEx' is not a function or function pointer
if (!pSetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:73:39: note: declared here
static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c: In function '_init_console_infoex':
../win32/pdcscrn.c:250:19: error: request for member 'cbSize' in something not a structure or union
console_infoex.cbSize = sizeof(console_infoex);
^
../win32/pdcscrn.c:252:10: error: called object 'pGetConsoleScreenBufferInfoEx' is not a function or function pointer
if (!pGetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:74:39: note: declared here
static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:255:19: error: request for member 'srWindow' in something not a structure or union
console_infoex.srWindow.Right++;
^
../win32/pdcscrn.c:256:19: error: request for member 'srWindow' in something not a structure or union
console_infoex.srWindow.Bottom++;
^
../win32/pdcscrn.c: In function '_get_colors':
../win32/pdcscrn.c:266:28: error: request for member 'cbSize' in something not a structure or union
if (!console_infoex.cbSize)
^
../win32/pdcscrn.c:269:42: error: request for member 'ColorTable' in something not a structure or union
(COLORREF *)(&(console_infoex.ColorTable));
^
../win32/pdcscrn.c: In function 'PDC_scr_open':
../win32/pdcscrn.c:455:10: error: 'GetConsoleScreenBufferInfoExFn' undeclared (first use in this function)
(GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:455:10: note: each undeclared identifier is reported only once for each function it appears in
../win32/pdcscrn.c:455:41: error: expected ';' before 'GetProcAddress'
(GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
^~~~~~~~~~~~~~
../win32/pdcscrn.c:458:10: error: 'SetConsoleScreenBufferInfoExFn' undeclared (first use in this function)
(SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:458:41: error: expected ';' before 'GetProcAddress'
(SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
^~~~~~~~~~~~~~
../win32/pdcscrn.c:352:13: warning: variable 'h_kernel' set but not used [-Wunused-but-set-variable]
HMODULE h_kernel;
^~~~~~~~
../win32/pdcscrn.c: In function 'PDC_init_pair':
../win32/pdcscrn.c:612:24: error: 'COMMON_LVB_REVERSE_VIDEO' undeclared (first use in this function)
att |= COMMON_LVB_REVERSE_VIDEO;
^~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:617:20: error: 'COMMON_LVB_UNDERSCORE' undeclared (first use in this function)
att |= COMMON_LVB_UNDERSCORE;
^~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:619:20: error: 'COMMON_LVB_GRID_LVERTICAL' undeclared (first use in this function)
att |= COMMON_LVB_GRID_LVERTICAL;
^~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c:621:20: error: 'COMMON_LVB_GRID_RVERTICAL' undeclared (first use in this function)
att |= COMMON_LVB_GRID_RVERTICAL;
^~~~~~~~~~~~~~~~~~~~~~~~~
../win32/pdcscrn.c: In function '_get_colors':
../win32/pdcscrn.c:277:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
gccwin32.mak:94: recipe for target 'pdcscrn.o' failed
mingw32-make: *** [pdcscrn.o] Error 1

How can I fix this ?

Build On OSX 10.14.1

I have build this On Win7(64Bit) and Ubuntu 18.04 and It works well.When I build this on OSX.
It tell me that i need <os2.h>. Does anyone know how to install this lib or how to solve this problem?

start_color broken?

If it is then it is a long standing bug.

The PDCurses documentation and the comments in pdcurses/color.c say:

start_color() initializes eight basic colors (black, red, green, yellow, blue, magenta, cyan, and white)

which is 100% identical to the ncurses documentation but likely should be (according to the switched default colors):

start_color() initializes eight basic colors (black, blue, green, yellow, red, magenta, cyan, and white)

But the real bug seems not the long-standing documentation but that after start_color() the first 8 pairs are all identical (foreground white, background black) . Shouldn't they be different?

I've glanced at the PDCurses source but could not find any place where those default pairs should be set. What did I miss?

Resize problem

#include <pdcurses/curses.h>

 void initWin(void) {
     initscr();
     noecho();
     keypad(stdscr, TRUE);
     cbreak();
     if (has_colors())
	  start_color();
 }

 int main(int argc, char const *argv[])
{
  initWin();
  refresh();
  int ch;
  int y, x;
  while ((ch = getch()) != 'q'){
	   if (is_termresized())
		   resize_term(0, 0);
	   getmaxyx(stdscr, y, x);
	   clear();
	   mvprintw(y / 2, x / 2 -20, "size: height:%d, width:%d\n", y, x);
	   refresh();
    }
    endwin();
    return 0;
}    

In above code, I run it and press some key, then I get the size (30, 120).After that I maximize the windows, I get the maximal size. Then I click to make window go back to normal size, I get (30, 117).
By repeating this process(max then normal), maximal size is always the same, but width of normal size will decrease by 3 each time, i.e. (30, 114), (30,111) ....Then window become smaller and smaller. Is it a bug?
In my test, linux ncurses (not pdcurses) work so well that you need not to resize it manually because getmaxyx will get changed size.
I build latest library in Win10 by mingw64

Windows 10 console can support more colors

...although it'll be quite kludgy. Microsoft has so far refused to provide API support for the extended console colors, giving access to them only through escape code sequences. Which ironically brings us back to the roots of curses... although I have in mind a hybrid implementation that will switch to escape-sequence mode only when needed.

sdl1+sdl2 missing install option

sdl2 has ยดinstall listed as ยด.PHONY target, but doesn't define the target itself. sdl1 has no mention of the install target at all.

Suggestion: create the target for both using something like the one used for x11.

Mouse position on scroll event is set to -1

For the WINCON port, when we use get a KEY_MOUSE event and use request_mouse_pos to get the event data, if it is a scroll event the x,y coordinates are both set to -1. This is happening here:

PDCurses/wincon/pdckbd.c

Lines 444 to 455 in 618e0aa

if (MEV.dwEventFlags == 4)
{
SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
SP->mouse_status.x = -1;
SP->mouse_status.y = -1;
memset(&old_mouse_status, 0, sizeof(old_mouse_status));
return KEY_MOUSE;
}

It seems intentional, but I am confused as to why we are doing this. It is easy to change these lines to report the actual coordinates.

Is there a different way we should be getting the mouse coordinates in the case of a scroll event or something else that I am missing here?

Build of 3.5 and 3.6 fails with MSVC 2005 and MSCV 2008

Hello here is the nmake output with error.

pdcscrn.c
..\wincon\pdcscrn.c(77) : error C2146: syntax error : missing ')' before identifier 'lpConsoleScreenBufferInfoEx'
..\wincon\pdcscrn.c(77) : error C2081: 'PCONSOLE_SCREEN_BUFFER_INFOEX' : name in formal parameter list illegal
..\wincon\pdcscrn.c(77) : error C2061: syntax error : identifier 'lpConsoleScreenBufferInfoEx'
..\wincon\pdcscrn.c(77) : error C2059: syntax error : ';'
..\wincon\pdcscrn.c(77) : error C2059: syntax error : ')'
..\wincon\pdcscrn.c(79) : error C2146: syntax error : missing ')' before identifier 'lpConsoleScreenBufferInfoEx'
..\wincon\pdcscrn.c(79) : error C2081: 'PCONSOLE_SCREEN_BUFFER_INFOEX' : name in formal parameter list illegal
..\wincon\pdcscrn.c(79) : error C2061: syntax error : identifier 'lpConsoleScreenBufferInfoEx'
..\wincon\pdcscrn.c(79) : error C2059: syntax error : ';'
..\wincon\pdcscrn.c(79) : error C2059: syntax error : ')'
..\wincon\pdcscrn.c(81) : error C2061: syntax error : identifier 'pSetConsoleScreenBufferInfoEx'
..\wincon\pdcscrn.c(81) : error C2059: syntax error : ';'
..\wincon\pdcscrn.c(81) : error C2513: '/global/ ' : no variable declared before '='
..\wincon\pdcscrn.c(82) : error C2061: syntax error : identifier 'pGetConsoleScreenBufferInfoEx'
..\wincon\pdcscrn.c(82) : error C2059: syntax error : ';'
..\wincon\pdcscrn.c(82) : error C2513: '/global/ ' : no variable declared before '='
..\wincon\pdcscrn.c(85) : error C2061: syntax error : identifier 'console_infoex'
..\wincon\pdcscrn.c(85) : error C2059: syntax error : ';'
..\wincon\pdcscrn.c(187) : error C2065: 'console_infoex' : undeclared identifier
..\wincon\pdcscrn.c(198) : warning C4550: expression evaluates to a function which is missing an argument list
..\wincon\pdcscrn.c(268) : error C2224: left of '.cbSize' must have struct/union type
..\wincon\pdcscrn.c(273) : error C2224: left of '.srWindow' must have struct/union type
..\wincon\pdcscrn.c(274) : error C2224: left of '.srWindow' must have struct/union type
..\wincon\pdcscrn.c(281) : warning C4550: expression evaluates to a function which is missing an argument list
..\wincon\pdcscrn.c(284) : error C2224: left of '.cbSize' must have struct/union type
..\wincon\pdcscrn.c(287) : error C2224: left of '.ColorTable' must have struct/union type
..\wincon\pdcscrn.c(287) : warning C4033: '_get_colors' must return a value
..\wincon\pdcscrn.c(476) : error C2065: 'GetConsoleScreenBufferInfoExFn' : undeclared identifier
..\wincon\pdcscrn.c(476) : warning C4047: '=' : 'int (__cdecl *)()' differs in levels of indirection from 'int '
..\wincon\pdcscrn.c(476) : error C2106: '=' : left operand must be l-value
..\wincon\pdcscrn.c(476) : error C2146: syntax error : missing ';' before identifier 'GetProcAddress'
..\wincon\pdcscrn.c(476) : warning C4550: expression evaluates to a function which is missing an argument list
..\wincon\pdcscrn.c(479) : error C2065: 'SetConsoleScreenBufferInfoExFn' : undeclared identifier
..\wincon\pdcscrn.c(479) : warning C4047: '=' : 'int (__cdecl *)()' differs in levels of indirection from 'int '
..\wincon\pdcscrn.c(479) : error C2106: '=' : left operand must be l-value
..\wincon\pdcscrn.c(479) : error C2146: syntax error : missing ';' before identifier 'GetProcAddress'
..\wincon\pdcscrn.c(479) : warning C4550: expression evaluates to a function which is missing an argument list
pdcsetsc.c

Cheers

Creation of deffont.bmp

Hi. The default bitmap font for cp437 has a mention about being generated from bdf fonts.
Is the program which generates this source readily available somewhere?
I would like to generate such bitmaps for different codepages.

Shrinking wincon vertically only generates a single KEY_RESIZE

On at least Windows 10, shrinking a console window by dragging the lower horizontal edge of the window upwards only generates a single initial KEY_RESIZE event if resize_term(0, 0) is used. A scrollbar also appears, indicating that the console buffer is larger than the console window.

Here's what's happening:

  1. getch() calls ReadConsoleInput(), gets a WINDOW_BUFFER_SIZE_EVENT for the initial shrinking (which would make the scrollbar appear, presumably), and returns KEY_RESIZE.

  2. resize_term(0, 0) is called, which calls PDC_resize_screen(0, 0), which never resizes the console buffer, because SetConsoleScreenBufferSize() is only called if nlines || ncols.

  3. getch() is called again, but doesn't get any more WINDOW_BUFFER_SIZE_EVENTs, because only the size of the console window changes and not the size of the console buffer.

Resizing the terminal horizontally clears up the issue. I'm guessing the console buffer is reallocated internally in that case.

The following patch makes the behavior more robust for wincon, but might be incorrect for other platforms (or have other issues), so I'm submitting it more as an RFC. You still get scrollbars if you drag the lower edge quickly upwards, but it's a big improvement nonetheless.

diff --git a/pdcurses/initscr.c b/pdcurses/initscr.c
index 95f23fe..4e42038 100644
--- a/pdcurses/initscr.c
+++ b/pdcurses/initscr.c
@@ -300,7 +300,15 @@ int resize_term(int nlines, int ncols)
 {
     PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
 
-    if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR)
+    if (!stdscr)
+        return ERR;
+
+    if (!(nlines || ncols)) {
+        nlines = PDC_get_rows();
+        ncols = PDC_get_columns();
+    }
+
+    if (PDC_resize_screen(nlines, ncols) == ERR)
         return ERR;
 
     SP->lines = PDC_get_rows();
diff --git a/wincon/pdcscrn.c b/wincon/pdcscrn.c
index daef0e3..3b52041 100644
--- a/wincon/pdcscrn.c
+++ b/wincon/pdcscrn.c
@@ -525,33 +525,30 @@ int PDC_resize_screen(int nlines, int ncols)
     SMALL_RECT rect;
     COORD size, max;
 
-    if (nlines || ncols)
-    {
-        if (nlines < 2 || ncols < 2)
-            return ERR;
+    if (nlines < 2 || ncols < 2)
+        return ERR;
 
-        max = GetLargestConsoleWindowSize(pdc_con_out);
+    max = GetLargestConsoleWindowSize(pdc_con_out);
 
-        rect.Left = rect.Top = 0;
-        rect.Right = ncols - 1;
+    rect.Left = rect.Top = 0;
+    rect.Right = ncols - 1;
 
-        if (rect.Right > max.X)
-            rect.Right = max.X;
+    if (rect.Right > max.X)
+        rect.Right = max.X;
 
-        rect.Bottom = nlines - 1;
+    rect.Bottom = nlines - 1;
 
-        if (rect.Bottom > max.Y)
-            rect.Bottom = max.Y;
+    if (rect.Bottom > max.Y)
+        rect.Bottom = max.Y;
 
-        size.X = rect.Right + 1;
-        size.Y = rect.Bottom + 1;
+    size.X = rect.Right + 1;
+    size.Y = rect.Bottom + 1;
 
-        _fit_console_window(pdc_con_out, &rect);
-        SetConsoleScreenBufferSize(pdc_con_out, size);
-        _fit_console_window(pdc_con_out, &rect);
-        SetConsoleScreenBufferSize(pdc_con_out, size);
-        SetConsoleActiveScreenBuffer(pdc_con_out);
-    }
+    _fit_console_window(pdc_con_out, &rect);
+    SetConsoleScreenBufferSize(pdc_con_out, size);
+    _fit_console_window(pdc_con_out, &rect);
+    SetConsoleScreenBufferSize(pdc_con_out, size);
+    SetConsoleActiveScreenBuffer(pdc_con_out);
 
     PDC_flushinp();
 
-- 
2.14.1

(Are those duplicated _fit_console_window()/SetConsoleScreenBufferSize() calls intentional by the way?)

Here's the interface of my application. Wanting to drag the lower edge of the window is very natural, but currently messes up scrolling if the window is made smaller.

38304415-abebe868-3809-11e8-97fb-63f2b097d041

install hyperion on kali linux by mingw64

i have problem on it.why it show this:
kali@kali:~$ sudo i686-mingw64msvc-c++ hyperion-2.3/Src/Crypter/*.cpp -o hyperion.exe
sudo: i686-mingw64msvc-c++: command not found
What command is right?

ๅฏนๅœจ็ฎ€ไฝ“ไธญๆ–‡็š„Window10ๅœจ้ป˜่ฎค็š„ๆŽงๅˆถๅฐๆ‰“ๅฐๅŒ…ๅซไธญๆ–‡็š„ๅญ—็ฌฆไธฒไผšๅ‡บ็ŽฐๆŽ’็‰ˆ้—ฎ้ข˜็š„ไฟฎๆ”น

ๅœจ็ฎ€ไฝ“ไธญๆ–‡็š„Window10้ป˜่ฎค็š„ๆŽงๅˆถๅฐๆ‰“ๅฐๅŒ…ๅซไธญๆ–‡็š„ๅญ—็ฌฆไธฒไผšๅ‡บ็ŽฐๆŽ’็‰ˆ้—ฎ้ข˜๏ผŒไธญๆ–‡ๅญ—็ฌฆไผšๅ ๅŠ ๅœจไธ€่ตท๏ผŒๆˆ‘่ฟฝ่ธชๅˆฐๅœจ่ฟ™้‡Œๅšไธ€ไบ›ไฟฎๆ”น๏ผŒๅฎž็Žฐๆญฃๅธธ็š„ไธญๆ–‡ๅญ—็ฌฆๆŽ’็‰ˆ๏ผŒๅฏๆˆ‘ๆฒกๆœ‰็ŽฏๅขƒๅŽปๆต‹่ฏ•ๆ—ฅๆ–‡๏ผŒ้Ÿฉๆ–‡ใ€็นไฝ“ไธญๆ–‡็ญ‰ไบšๆดฒๅœฐๅŒบๅŠๅ…ถไป–ๅ›ฝๅฎถ็š„ๆ–‡ๅญ—ใ€‚

ไปฅไธ‹ๆ˜ฏๆˆ‘ไฟฎๆ”น่ฟ‡็š„ๅ†…ๅฎน๏ผš

int waddnstr(WINDOW *win, const char *str, int n)
{
    int i = 0;

    PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n));

    if (!win || !str)
        return ERR;

    while (str[i] && (i < n || n < 0))
    {
#ifdef PDC_WIDE
        wchar_t wch;
        int retval = PDC_mbtowc(&wch, str + i, n >= 0 ? n - i : 6);

        if (retval <= 0)
            return OK;

        i += retval;
#else
        chtype wch = (unsigned char)(str[i++]);
#endif

#ifdef PDC_WIDE
	int x = win->_curx;
	int y = win->_cury;

	if (1==retval){
            waddch(win, ' ');
            wmove(win, y, x);
        }

	if (3==retval){
	   if( 0 !=x ){
              wmove(win, y, x-1);
              waddch(win, ' ');
              waddch(win, ' ');
              waddch(win, ' ');
              wmove(win, y, x);
            }
        }
#endif

        if (waddch(win, wch) == ERR)
            return ERR;

#ifdef PDC_WIDE
	if (3==retval){
		win->_curx+=1;
	}
#endif

    }

    return OK;
}

ไฟฎๆ”น็š„ๆ–นๅผๆฏ”่พƒ็ฒ—ๆšด๏ผŒๅฆ‚ๆžœๅŽŸไฝœ่€…่ƒฝๅคŸๅšๅฎ˜ๆ–นไฟฎๆ”นๅฐฑๆ›ดๅฅฝไบ†ใ€‚

sdl2 port accepts keys when not in front

Only happens with sdl2 port; sdl1 and x11 behave properly. Also only tested on Linux.
Problem is if you have a sdl2 PDCurses program running, waiting for keystrokes, and you have a terminal window on top of the PDCurses window; if you close the teminal window via ^D or exit, the last keystroke in the terminal window (^D or ^M) is accepted by the PDCurses program.
To setup, start sdl2 port of testcurs, and go to 'Input Test'. Open a terminal window and place over the top of testcurs. With terminal window on top and focused, press ^D to close terminal window. Terminal window closes AND ^D shows up in testcurs. Terminal window doesn't have to be overlapped, as long as testcurs is next window in z-order.

Redirection is not support.

I clone your repo and built pdcurses in ../wincon.
I got pdcurses.a. Ok. Next, I decided write simple test program and compile it:

main.c:

#include <stdio.h>

#include <curses.h>

int
main(void) {
    initscr();
    printw("Hello, World!\n");
    refresh();
    endwin();
    return 0;
}

How I compiled it: gcc -I ~/source/PDCurses/ main.o ~/source/PDCurses/wincon/pdcurses.a -o prog

It's good. Next, I run ./prog.exe and see an error: Redirection is not supported.

I searching solution this problem, but i found only for nano text editor (it's run perfectly for me), because i'm writing here.

I'm using cygwin in windows.

Changes from 3.4 to 3.5 on Windows?

Hi guys,

I am trying to get version 3.5 to work on Windows 10 x64 as a DLL, without much success. The initscr, printw, refresh and endwin function do nothing.
Then I downloaded and compiled version 3.4 from source and it works without problems.

I am using the compiled DLL with the Nim programming language.
My specs:

  • OS: Windows 10 x64
  • Compiler: gcc (x86_64-win32-seh-rev1, Built by MinGW-W64 project) 7.2.0

Equivalent C sample code to my Nim code:

initscr();
printw(curses_version());
refresh();
endwin();

I apologize if I am missing something basic, but I only recently started playing around with PDCurses and am not well versed in its concepts.

How to build X11 shared library?

Hi,

System: Raspbian (Raspberry Pi)

I cannot find any documentation of how to build a shared library (.so) on X11/Linux.
The x11/README.md procedure only builds the static library (.a) and 'make install' throws an error:

./install-sh -d -m 755 
install:  no input file specified
Makefile:55: recipe for target 'install' failed
make: *** [install] Error 1

Thanks

[error]Compile PDCurses in win10

OS:win10 1709
compiler:mingw gcc5.1.0 (tdm-1)
command:mingw32-make.exe -f makefile WIDE=Y UTF8=Y
error:

../wincon/pdcdisp.c: In function '_new_packet':
../wincon/pdcdisp.c:211:28: error: 'COMMON_LVB_UNDERSCORE' undeclared (first use in this function)
             mapped_attr |= COMMON_LVB_UNDERSCORE;
                            ^
../wincon/pdcdisp.c:211:28: note: each undeclared identifier is reported only once for each function it appears in
../wincon/pdcdisp.c:213:28: error: 'COMMON_LVB_GRID_LVERTICAL' undeclared (first use in this function)
             mapped_attr |= COMMON_LVB_GRID_LVERTICAL;
                            ^
../wincon/pdcdisp.c:215:28: error: 'COMMON_LVB_GRID_RVERTICAL' undeclared (first use in this function)
             mapped_attr |= COMMON_LVB_GRID_RVERTICAL;
                            ^
makefile:94: recipe for target 'pdcdisp.o' failed
mingw32-make: *** [pdcdisp.o] Error 1

Please add configurable WINDRES variable to wincon/Makefile

When using cross-compilers, windres has various prefixes. A patch like that helps:

diff --git a/wincon/Makefile b/wincon/Makefile
index 6c5808f..46e0c34 100644
--- a/wincon/Makefile
+++ b/wincon/Makefile
@@ -30,6 +30,7 @@ CC = gcc
AR = ar
STRIP = strip
LINK = gcc
+WINDRES = windres

ifeq ($(DEBUG),Y)
CFLAGS = -g -Wall -DPDCDEBUG
@@ -87,7 +88,7 @@ $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS) $(RESOURCE)
$(LIBEXE) $(LIBFLAGS) $@ $?

pdcurses.o: $(common)/pdcurses.rc

  • windres -i $(common)/pdcurses.rc pdcurses.o
  • $(WINDRES) -i $(common)/pdcurses.rc pdcurses.o

$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
$(PDCOBJS) : $(PDCURSES_WIN_H)

wincon: re-add HAVE_INFOEX

Moved from discussion in #27.

@wmcbrine removed the HAVE_INFOEX definition from win32/pdcwin.h with d9fb37d ("Dropped support for Digital Mars.") which breaks building with other environments like MinGW, too.

While mingw-w64 has CONSOLE_SCREEN_BUFFER_INFOEX it is generally not available with the "original" MinGW environment, even when updated (there is a MinGW ticket for this issue).

But even with an updated version the "new" wincon.h wouldn't be available for many old environments.

Despite the minimal clutter the old defines add there is no bad part about it (it doesn't break new environments), therefore I'd like to see it back with the minimal entry in wincon/pdcwin.h like:

#if !defined(HAVE_INFOEX) && !defined(HAVE_NO_INFOEX)
# define HAVE_INFOEX
#endif

This way all environments will default to have it and when building with "old" environments the option "-DHAVE_NO_INFOEX` exists.

Screen write only happens when reading a key

The x11 and sdl2 ports of PDCurses will only write the contents of curses windows to the screen when a key is being read; not at the time doupdate() is called.

This is not the same behaviour of ncurses or the original x11 port.

If I run a macro in my editor that results in the contents of a curses window to be changed, and I call doupdate(), this change is not reflected on the screen until I accept a key from the keyboard.

init_color makes BadAccess (opcode 88) in X11

When the first argument of init_color is more than 17, it will raise an error.

#include "curses.h"

int main(){
  initscr();
  start_color();
  init_color(17,0,0,0);
  endwin();
  return 0;
}

In X11 environment (I'm using debian9), I compiled above code with gcc like this:
gcc test.c -lXCurses -lX11 -lSM -lXaw -lXmu -lXt -lXpm -lICE
It successfully compiled.However, when I ran the executable, it fails with this error message:

X Error of failed request:  BadAccess (attempt to access private resource denied)
  Major opcode of failed request:  88 (X_FreeColors)
  Serial number of failed request:  1030
  Current serial number in output stream:  1082

COLORS is set to 256, therefore init_color should be able to change more than 16 color definitions.
init_color test is only done in a range of 0 to 16 in a demo file (testcurs.c), so the demo works fine.

SDL2 unable to set colors correctly

Hello. In a program which uses SDL2 pdcurses, the colors are not what they should be when I attempt to set a custom scheme. I'm trying to assign tango colors to the set of the basic 16 colors.

Under ncurses and a 256-color xterm, setting a color scheme with this code works.
I put a screen capture of the two, to be able to visualize the difference.

    start_color();

    constexpr uint32_t tango_colors[16] = {
        0x2e3436, 0xcc0000, 0x4e9a06, 0xc4a000,
        0x3465a4, 0x75507b, 0x06989a, 0xd3d7cf,
        0x555753, 0xef2929, 0x8ae234, 0xf57900,
        0x729fcf, 0xad7fa8, 0x34e2e2, 0xeeeeec,
    };
    for (unsigned i = 0; i < 16; ++i) {
        unsigned r = (tango_colors[i] >> 16) & 0xff;
        unsigned g = (tango_colors[i] >> 8) & 0xff;
        unsigned b = (tango_colors[i] >> 0) & 0xff;
        init_color(i, r * 1000 / 0xff, g * 1000 / 0xff, b * 1000 / 0xff);
    }

color-pdcurses

color-xterm

Create PDC_version_info structure and option to receive it at run-time

Providing this helps external applications to get detailed information about

  • the actual version, both for compilation (PDCurses has only PDC_BUILD so far, a more detailed version would be nice) and at run-time:
#define PDC_VER_MAJOR    3
#define PDC_VER_MINOR    6
#define PDC_VER_CHANGE   1
#define PDC_VER_YEAR   2018
#define PDC_VER_MONTH   12
#define PDC_VER_DAY     02

#define PDC_BUILD (PDC_VER_MAJOR*1000 + PDC_VER_MINOR *100 + PDC_VER_CHANGE)
  • the build options (size of chtype, wide, ...), available at run-time
  • the actual variant of PDCurses in use at run-time

This was previously committed to the BillGray fork in 9b2cdad, 08fd141, 42ff4f6.

Using the exact same structure and external name would obviously be very good as it also allows to switch the shared object versions (as long as no other ABI-difference is used, but luckily there aren't so much "external" differences).

Broken length clipping in winsnstr() and wins_nwstr()

winsnstr() and wins_nwstr() print too many characters when the n argument is greater than the length of the string, due to two broken checks:

if (n < 0 || n < len)

if (n < 0 || n < len)

I think it was meant to be

if (n < 0 || n > len)

It looks like the n < strlen(s) case might be broken too.

I think this is what's causing zephyrproject-rtos/windows-curses#2.

Clipboard functions for x11new

x11new currently lacks working clipboard functions. If I copy xclip.c from

https://github.com/Bill-Gray/junk

to the x11new directory, and rename it to pdcclip.c, and add -lpthreads to the libraries in the Makefile, it compiles and the testcurs tests work (after setting HAVE_CLIPBOARD to 1).

I originally wrote this to add clipboard functions for the VT platform. This code will work for both. It also has the nice feature (in my opinion) of allowing one to use the PDC_*clipboard functions in any program, including those not linked to the PDCurses library, including those that are linked to ncurses.

Note that by changing a couple of strings from CLIPBOARD to PRIMARY, you can switch from setting/getting the clipboard to setting/getting the current selection. I've not made it possible yet to make that switch programmatically, but am strongly tempted to do so.

A question : I see you're still making improvements to the "original" fork()-using x11 platform. Do you expect that to fade away now that we've got x11new to play with? Is there still a use for the "original" platform?

PDC_DLL_BUILD (was: getch() causes crash, wgetch with return from initscr does not)

I am experiencing an issue using pdcurses 3.4-1 (x86-windows, sourced from vcpkg) with VS2015.

This issue seems to have been seen at least once before on StackOverflow.

The issue is that when using stdscr with getch, I receive a crash.

#include <curses.h>

int main()
{
    initscr();
    printw("Hello pdcurses");
    refresh();
    getch();
    endwin();

    return 0;
}

The above sample code results in this crash and callstack:

Exception thrown: read access violation.
win was 0x6B9E9.
>	pdcurses.dll!wgetch(_win * win) Line 174	C

If I modify the code to use the return value of initscr, everything works as expected.

#include <curses.h>

int main()
{
    auto scr = initscr();
    printw("Hello pdcurses");
    refresh();
    wgetch(scr);
    endwin();

    return 0;
}

Edit:
Stepping through it with a debugger, I discovered that stdscr and my local scr do not match. Breakpointing from the start of main, I can see that stdscr is not being initialized by initscr.

This is a DLL build.

doc broken

Previously there was a working doc folder that uses GitHub Pages.
After the change in the doc structure this was not updated yet, therefore the link

https://pdcurses.org/doc/

is broken.
I suggest to adjust the GitHub Pages configuration to the new URL.

I can compile pdcurses3.4 but can't compile curse3.6

I am using the mingw compiler with codeblocks and when I try to compile I get these error messages. How do I solve this problem? I have using gcc.exe (tdm-1) 5.1.0 of the compiler which is quite current I think.
PS D:\Download\PDCurses-master\PDCurses-master\wincon> mingw32-make -f Makefile gcc -c -O2 -Wall -I.. ../pdcurses/addch.c gcc -c -O2 -Wall -I.. ../pdcurses/addchstr.c gcc -c -O2 -Wall -I.. ../pdcurses/addstr.c gcc -c -O2 -Wall -I.. ../pdcurses/attr.c gcc -c -O2 -Wall -I.. ../pdcurses/beep.c gcc -c -O2 -Wall -I.. ../pdcurses/bkgd.c gcc -c -O2 -Wall -I.. ../pdcurses/border.c gcc -c -O2 -Wall -I.. ../pdcurses/clear.c gcc -c -O2 -Wall -I.. ../pdcurses/color.c gcc -c -O2 -Wall -I.. ../pdcurses/delch.c gcc -c -O2 -Wall -I.. ../pdcurses/deleteln.c gcc -c -O2 -Wall -I.. ../pdcurses/deprec.c gcc -c -O2 -Wall -I.. ../pdcurses/getch.c gcc -c -O2 -Wall -I.. ../pdcurses/getstr.c gcc -c -O2 -Wall -I.. ../pdcurses/getyx.c gcc -c -O2 -Wall -I.. ../pdcurses/inch.c gcc -c -O2 -Wall -I.. ../pdcurses/inchstr.c gcc -c -O2 -Wall -I.. ../pdcurses/initscr.c gcc -c -O2 -Wall -I.. ../pdcurses/inopts.c gcc -c -O2 -Wall -I.. ../pdcurses/insch.c gcc -c -O2 -Wall -I.. ../pdcurses/insstr.c gcc -c -O2 -Wall -I.. ../pdcurses/instr.c gcc -c -O2 -Wall -I.. ../pdcurses/kernel.c gcc -c -O2 -Wall -I.. ../pdcurses/keyname.c gcc -c -O2 -Wall -I.. ../pdcurses/mouse.c gcc -c -O2 -Wall -I.. ../pdcurses/move.c gcc -c -O2 -Wall -I.. ../pdcurses/outopts.c gcc -c -O2 -Wall -I.. ../pdcurses/overlay.c gcc -c -O2 -Wall -I.. ../pdcurses/pad.c gcc -c -O2 -Wall -I.. ../pdcurses/panel.c gcc -c -O2 -Wall -I.. ../pdcurses/printw.c gcc -c -O2 -Wall -I.. ../pdcurses/refresh.c gcc -c -O2 -Wall -I.. ../pdcurses/scanw.c gcc -c -O2 -Wall -I.. ../pdcurses/scr_dump.c gcc -c -O2 -Wall -I.. ../pdcurses/scroll.c gcc -c -O2 -Wall -I.. ../pdcurses/slk.c gcc -c -O2 -Wall -I.. ../pdcurses/termattr.c gcc -c -O2 -Wall -I.. ../pdcurses/terminfo.c gcc -c -O2 -Wall -I.. ../pdcurses/touch.c gcc -c -O2 -Wall -I.. ../pdcurses/util.c gcc -c -O2 -Wall -I.. ../pdcurses/window.c gcc -c -O2 -Wall -I.. ../pdcurses/debug.c gcc -c -O2 -Wall -I.. ../wincon/pdcclip.c gcc -c -O2 -Wall -I.. ../wincon/pdcdisp.c gcc -c -O2 -Wall -I.. ../wincon/pdcgetsc.c gcc -c -O2 -Wall -I.. ../wincon/pdckbd.c gcc -c -O2 -Wall -I.. ../wincon/pdcscrn.c ../wincon/pdcscrn.c:77:5: error: unknown type name 'PCONSOLE_SCREEN_BUFFER_INFOEX' PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx); ^ ../wincon/pdcscrn.c:79:5: error: unknown type name 'PCONSOLE_SCREEN_BUFFER_INFOEX' PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx); ^ ../wincon/pdcscrn.c:81:8: error: unknown type name 'SetConsoleScreenBufferInfoExFn' static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL; ^ ../wincon/pdcscrn.c:82:8: error: unknown type name 'GetConsoleScreenBufferInfoExFn' static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL; ^ ../wincon/pdcscrn.c:85:8: error: unknown type name 'CONSOLE_SCREEN_BUFFER_INFOEX' static CONSOLE_SCREEN_BUFFER_INFOEX console_infoex; ^ ../wincon/pdcscrn.c: In function '_set_console_infoex': ../wincon/pdcscrn.c:187:10: error: called object 'pSetConsoleScreenBufferInfoEx' is not a function or function pointer if (!pSetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex)) ^ ../wincon/pdcscrn.c:81:39: note: declared here static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL; ^ ../wincon/pdcscrn.c: In function '_init_console_infoex': ../wincon/pdcscrn.c:268:19: error: request for member 'cbSize' in something not a structure or union console_infoex.cbSize = sizeof(console_infoex); ^ ../wincon/pdcscrn.c:270:10: error: called object 'pGetConsoleScreenBufferInfoEx' is not a function or function pointer if (!pGetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex)) ^ ../wincon/pdcscrn.c:82:39: note: declared here static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL; ^ ../wincon/pdcscrn.c:273:19: error: request for member 'srWindow' in something not a structure or union console_infoex.srWindow.Right++; ^ ../wincon/pdcscrn.c:274:19: error: request for member 'srWindow' in something not a structure or union console_infoex.srWindow.Bottom++; ^ ../wincon/pdcscrn.c: In function '_get_colors': ../wincon/pdcscrn.c:284:28: error: request for member 'cbSize' in something not a structure or union if (!console_infoex.cbSize) ^ ../wincon/pdcscrn.c:287:42: error: request for member 'ColorTable' in something not a structure or union (COLORREF *)(&(console_infoex.ColorTable)); ^ ../wincon/pdcscrn.c: In function 'PDC_scr_open': ../wincon/pdcscrn.c:476:10: error: 'GetConsoleScreenBufferInfoExFn' undeclared (first use in this function) (GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel, ^ ../wincon/pdcscrn.c:476:10: note: each undeclared identifier is reported only once for each function it appears in ../wincon/pdcscrn.c:476:41: error: expected ';' before 'GetProcAddress' (GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel, ^ ../wincon/pdcscrn.c:479:10: error: 'SetConsoleScreenBufferInfoExFn' undeclared (first use in this function) (SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel, ^ ../wincon/pdcscrn.c:479:41: error: expected ';' before 'GetProcAddress' (SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel, ^ ../wincon/pdcscrn.c:366:13: warning: variable 'h_kernel' set but not used [-Wunused-but-set-variable] HMODULE h_kernel; ^ ../wincon/pdcscrn.c: In function '_get_colors': ../wincon/pdcscrn.c:295:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ Makefile:95: recipe for target 'pdcscrn.o' failed mingw32-make: *** [pdcscrn.o] Error 1 PS D:\Download\PDCurses-master\PDCurses-master\wincon>

ncurses mouse api: crashes if not initialized

To reproduce just place a

	int mouse_interval = mouseinterval (-1);

somewhere before the PDCurses initialization. Result: SIGSEGV.
The man page says for this function similar for others):

returns the previous interval value, unless the terminal was not initialized. In that case, it returns the maximum interval value (166).

I'm confident that the SIGSEGV roots in direct unchecked access to SP->, so the "correct thing to match the documentation" is to check it here (and possibly in other places) and return the maximum.
Note: the maximum in PDCurses is 1000 (seems arbitrary, in any case likely a good candidate for a define, maybe useful to switch to ncurses' value [if I'm not wrong it will use the maximum if you specify something higher, PDCurses ignores the value in this case]).

subwin compatibility problem

Hi,

The following subwin example* didn't work with PDCurses.
It shows just blank page instead of sub windows.
is this might be caused by a compatibility problem?

Environment: Windows 10 (1803), Visual Studio 2017 & PDCurses wincon

* Programmer's Guide to NCurses, page 286

#include <curses.h>

int main(void)
{
	WINDOW *subby,*sonny;
	int row,col;

	initscr();
	start_color();
	init_pair(1,COLOR_WHITE,COLOR_BLUE);
	init_pair(2,COLOR_YELLOW,COLOR_RED);

	subby = newwin(10,30,10,40);
	wbkgd(subby,COLOR_PAIR(1));
	getparyx(subby,row,col);
	wprintw(subby,"This subwin's org: %d, %d.",row,col);
	wrefresh(subby);
	
	sonny = subwin(subby,7,30,13,40);
	wbkgd(sonny,COLOR_PAIR(2));
	getparyx(sonny,row,col);
	wprintw(sonny,"This subwin's org: %d, %d.",row,col);
	wrefresh(sonny);

	getch();

	endwin();
	return 0;
}

example_subwin

How to build 32x windows dll with mingw-w64

Tried calling make CFLAGS="-m32" DLL=Y, linking fails with a lot of undefined symbols.

tried editing CC and LINK in the makefile to use -m32, same result.

Need to use it with a 32 bit compiler, but it refuses to build in anything but 64 bits.

Thanks for any help.

ozdemo: fix GCC truncation warning

../demos/ozdemo.c: In function 'main':
../demos/ozdemo.c:355:17: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
                 strncpy(scrollbuf + i, message, msg_len);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../demos/ozdemo.c:345:27: note: length computed here
             int msg_len = strlen(message);
                           ^~~~~~~~~~~~~~~

proudly presented by

gcc.exe (Rev1, Built by MSYS2 project) 8.2.0

Is Alt-Gr implemented?

I'm using the Textadept editor which uses PDCurses on Windows. On my German Windows the Alt-Gr key (responsible for \ and | and {[]} does not work.

The developer responded (https://foicica.com/lists/code/201609/3349.html)

I cannot find any mention of AltGr handling in the PDCurses source code,
so I don't think this issue can be fixed :( Sorry.

Is that correct? Can it be fixed or implemented?

nc mouse compatibility: missing has_mouse

ncurses 5.3 added _nc_has_mouse to check if the mouse can actually be handled by the library. ncurses 5.8 renamed it to has_mouse. Both functions are not defined in (pd)curses.h.

Questions:

  • Should PDCurses' define the "old" _nc_has_mouse along to the current has_mouse?
  • Should this/these only be defined if the ncurses mouse compatibility is active (if we add the first, too then at least that should be defined if explicit requested)?
  • Is there an option in pdcurses to check if the mouse is active [in terms of "can be used within PDCurses"]? If not: should this function always return TRUE?

Demo programs (SDL2) freeze when dragged to 2nd monitor on macos

I have installed the SDL2 and SDL2_ttf frameworks (v2.0.9) on a MacBook running macos 10.14.4 (Mojave) which has a second monitor attached. I can run the demos successfully on the laptop screen, but when I drag the demo program window to the second monitor the demo program freezes. All I can do is close the window.
If I start a demo program from the second monitor, it displays on the laptop screen. Again dragging to the second monitor freezes the program.
I assume that SDL2 doesn't work on a second monitor, but I can't find any bug reports against SDL2 related to this.

PDCurses does not restore some console mode flags correctly on Windows

Since GetConsoleMode does not return ENABLE_EXTENDED_FLAGS (0x0080),

GetConsoleMode(pdc_con_in, &old_console_mode);
SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
               (ENABLE_MOUSE_INPUT|0x0088) : (pdc_quick_edit|0x0088));
SetConsoleMode(pdc_con_in, old_console_mode);

will not preserve ENABLE_INSERT_MODE and ENABLE_QUICK_EDIT_MODE (if SP->_trap_mbe is true).

I hit this bug when I used chistedit curses UI that Mercurial 4.9 introduced. Everytime I run hg histedit, I have to re-enable Insert mode and QuickEdit mode from the Properties dialog.

Windows console size freezes after repeated resizing.

Hi,

I experienced Windows 10 console size freezes with my own application (wcd). It can be reproduced with the rain demo program. Sometimes the application freezes also.

Take the rain demo program, compiled for Windows console. I used mingw-w64 64 bit. Start it in a Windows 10 console. Grab with the mouse an edge of the console and keep resizing. After a while the console freezes and can't be resized any more. Sometimes the rain application continues to run (in a fixed size console) and sometimes the rain application freezes also.
When you are able to exit the rain program after a console freeze, the console size stays frozen.
When the rain application also freezes, the only way out is to terminate the console.

best regards,

Erwin Waterlander

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.