Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6186191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:50:40+00:00 2026-05-24T01:50:40+00:00

i am trying to learn ncurses library and i came up with code below:

  • 0

i am trying to learn ncurses library and i came up with code below:

#include <ncurses.h>
#include <stdlib.h>
#include <signal.h>

static void finish(int sig);

int main(int argc, char** argv) {

    char c;
    initscr();
    raw();
    keypad(stdscr, TRUE);
    noecho();

    (void) signal(SIGINT, finish);      /* arrange interrupts to terminate */

    printw("Type any character to see it in bold:\n");
    refresh();
    c = getch();

    /* work around for ctrl+c */
    if(c == 3)
        finish(0);

    while(c != KEY_F(1))
    {
        printw("The pressed key is ");
        attron(A_BOLD);
        printw("%c\n", c);
        attroff(A_BOLD);
        refresh();
        c = getch();

        /* work around for ctrl+c */
        if(c == 3)
            finish(0);

        printf("Code = %d\n", c);
    }

    printw("F1 key pressed.\n");
    endwin();

    return (EXIT_SUCCESS);
}

static void finish(int sig)
{
    endwin();

    /* do your non-curses wrapup here */

    exit(0);
}

The problem in this code is when i press F1 key, terminal help window opens and i can’t catch F1 key press. Also i can’t catch ctrl+c press by signal mechanism. Is there any way to override F1 key on terminal and how can i use signals in curses mode.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:50:40+00:00Added an answer on May 24, 2026 at 1:50 am

    In the terminal window’s menu bar, Edit -> Preferences. Go to the Shortcuts tab. Clear the conflicting shortcuts.

    Better yet, don’t use any shortcuts that conflict with the terminal emulator’s pre-existing shortcuts.

    You should probably leave SIGINT alone. ncurses already intercepts it to clean up the terminal before exit. If you need to run some cleanup code of your own, try the atexit function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While trying to learn Unity , I keep seeing the following code for overriding
Im trying to learn glib/gtk. I wrote little code which prints files in directory
Trying to learn pointer math better I wrote this code. The intention was to
Trying to learn pointers better I wrote this code. The intention was to print
Im trying to learn javascript by tracing through some code at the moment, I
I was looking at some Cappuccino code (trying learn a little bit of it)
I'm trying to learn WCF and I've created a new WCF Service Library project
Im trying to learn alot more about C code by trying to do the
Trying to learn a bit of CSS and I want a horizontal navbar and
Trying to learn a bit about PDO and is going through this tutorial .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.