Skip to content

Commit

Permalink
'focus.c' test program now cleans up memory appropriately. Modified t…
Browse files Browse the repository at this point in the history
…he comment section to point out that the framebuffer and DRM ports could also support define_key() (I have no real plans for doing that on _any_ platform at present, though).
  • Loading branch information
Bill-Gray committed Apr 25, 2024
1 parent 94dbde4 commit 5e2a1c8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/focus.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <curses.h>

/* Test code for define_key(). At present, this function
does nothing in PDCurses*. It could be added to the VT platform,
if that proves desirable. More generally, though, I'm thinking
that the ability to get KEY_FOCUS_IN and KEY_FOCUS_OUT via getch(),
on all platforms, might be useful. At present, our programs
have no way of knowing if they've lost/regained focus.
does nothing in PDCurses*. It could be added to the VT and
Linux framebuffer/DRM platforms, if that proves desirable.
More generally, though, I'm thinking that the ability to get
KEY_FOCUS_IN and KEY_FOCUS_OUT via getch(), on all platforms,
might be useful. At present, our programs have no way of
knowing if they've lost/regained focus.
If we did such a thing, the following bits would still be
needed for portable programs. That is to say, if you weren't
Expand All @@ -21,8 +22,8 @@ so that those events would be sent to the program. */
int main( void)
{
int input;
SCREEN *screen_pointer = newterm(NULL, stdout, stdin);

initscr();
noecho();
cbreak();
keypad( stdscr, 1);
Expand All @@ -45,6 +46,8 @@ int main( void)
addstr( keyname( input));
addch( ' ');
}
endwin();
endwin( );
/* Not really needed, but ensures Valgrind */
delscreen( screen_pointer); /* says all memory was freed */
return( 0);
}

0 comments on commit 5e2a1c8

Please sign in to comment.