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

  • SEARCH
  • Home
  • 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 6386455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:01:43+00:00 2026-05-25T03:01:43+00:00

I am making an interpreted language. I use an interactive prompt where I enter

  • 0

I am making an interpreted language. I use an interactive prompt where I enter expressions to be evaluated (a REPL). I was wondering, how do I implement standard prompt behavior? Like pressing the up and down arrow keys to navigate command history, and pressing the left and right arrow keys to move the text cursor, instead of printing the ^[[D^[[C^[[A^[[B codes. I just don’t know how to catch them, or any control characters in general.

I’m on Linux. Will I need to use ncurses or some external library, or can it be done with built-in functions? This is unrelated to my language, but it drives me mad to use the prompt like this, with no navigation. It makes testing more difficult.

  • 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-25T03:01:44+00:00Added an answer on May 25, 2026 at 3:01 am

    Here is an example C program that lets you do just that using readline (must be compiled with -lncurses -lreadline):

    #include <stdio.h>
    #include <curses.h>
    #include <readline/readline.h>
    #include <readline/history.h>
    
    int main (void) {
        char *input = readline("$ ");
        printf("You typed `%s'!\n", input);
        return 0;
    }
    

    Basically, it mimics the command line behavior for meta keys like home/end and the directional arrow keys. But that all depends on whether you have your inputrc correctly configured.

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

Sidebar

Related Questions

I am making my own Lisp-like interpreted language, and I want to do tail
Making an adobe flex ui in which data that is calculated must use proprietary
I've had a question that I've been wondering for a while. I'm making a
I've been making my way through The Little Schemer and I was wondering what
It's common for a programming language to come with a standard library implemented at
I would like to execute my javascript programs with the Rhino shell without making
I'm making my own javascript-based programming language (yeah, it is crazy, but it's for
I'm makin' a scripting language interpreter using PHP. I have this code in that
Making echo of a question around the web: Is the syntax for svn:ignore patterns
Making my first steps with NHibernate, I'm trying to have it creating my Tables

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.