LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-04-2017, 09:43 PM   #1
alberg
Member
 
Registered: Jun 2016
Distribution: Arch, Slackware
Posts: 47

Rep: Reputation: Disabled
Is there a library for creating console dialog boxes in C program?


Greetings,

is there a software library that can be used in a C program for creating dialog boxes in console without graphical environment (that is, not zenity or dialog)? Maybe some ncurses wrapper which simplifies creating dialog boxes with edit fields, buttons, labels, combo boxes and radio buttons?

I'm currently use ncurses, but defining every dialog box in every program , especially when there are few of them, is rather verbose.

Last edited by alberg; 01-05-2017 at 02:57 AM.
 
Old 01-05-2017, 02:13 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,487

Rep: Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530Reputation: 5530
http://stackoverflow.com/questions/2...e-command-line
https://pagure.io/newt
 
1 members found this post helpful.
Old 01-05-2017, 02:56 AM   #3
alberg
Member
 
Registered: Jun 2016
Distribution: Arch, Slackware
Posts: 47

Original Poster
Rep: Reputation: Disabled
pan64,

thanks, never heard of Newt. Looks interesting.
 
Old 01-10-2017, 11:58 AM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,982

Rep: Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569Reputation: 4569
http://invisible-island.net/cdk/
 
Old 01-10-2017, 02:51 PM   #5
patrick295767
Member
 
Registered: Feb 2006
Distribution: FreeBSD, Linux, Slackware, LFS, Gparted
Posts: 660

Rep: Reputation: 137Reputation: 137
Code:


#include <ncurses.h>


void drawit(){
        int rows, cols;  
        getmaxyx( stdscr, rows, cols);
        mvprintw(5 , 5, "Hello World !!!");	/* Print Hello World		  */
        mvprintw(rows-1 , 0, "<Press Key to Continue>");
}


int main()
{	
	initscr();			/* Start curses mode 		  */
        curs_set( 0 );

        drawit();

	refresh();			/* Print it on to the real screen */
	getch();			/* Wait for user input */

        curs_set( 1 );
	endwin();			/* End curses mode		  */
	return 0;
}






                   #include <stdio.h>
                   #include <stdlib.h>
                   #include <termcap.h>

                   void clear_screen()
                   {
                   char buf[1024];
                   char *str;
                   tgetent(buf, getenv("TERM"));
                   str = tgetstr("cl", NULL);
                   fputs(str, stdout);
                   }



int main()  
{  
   clear_screen();
   return 0;
}





/*
 * aclock - ascii clock for UNIX Console
 *
 * Copyright (c) 2002 Antoni Sawicki <as@tenoware.com>
 * Version 2.3 (unix-curses); Mountain View, July 2013
 *
 * Compilation: cc aclock-unix-knr.c -o aclock -lcurses -lm
 *
 * this is K&R version modified for old unices (but still with curses)
 *
 */

#include <unistd.h>
#include <ncurses.h>
#include <math.h>
#include <time.h>

int ch ; 


#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#define FontWH_Ratio 2

nrclock_drw_cir(hand_max, sycen, sxcen)
int hand_max; int sycen; int sxcen;
{
	int x,y,r;
	char c;

	for(r=0;r<60;r++){
		x=cos(r*M_PI/180*6)*hand_max*FontWH_Ratio+sxcen;
		y=sin(r*M_PI/180*6)*hand_max+sycen;
		switch (r) {
			case 0:
			case 5:
			case 10:
			case 15:
			case 20:
			case 25:
			case 30:
			case 35:
			case 40:
			case 45:
			case 50:
			case 55:
				c='o';
				break;
			default:
				c='.';
				break;
		}
		mvaddch(y,x,c);
	}
}

nrclock_draw_hand(minute, hlenght, c, sxcen, sycen)
int minute; int hlenght; char c; int sxcen; int sycen;
{
	int x,y,n;
	float r=(minute-15)*(M_PI/180)*6;

	for(n=1; n<hlenght; n++){
		x=cos(r)*n*FontWH_Ratio+sxcen;
		y=sin(r)*n+sycen;
		mvaddch(y,x,c);
	}
}




void nrclock(){
	char digital_time[15];
	int sXmax, sYmax, smax, hand_max, sXcen, sYcen;
	long t;
	struct tm *ltime;

	// initscr();
	// for(;;){
        int nrclock_gameover =  0;
   curs_set( 0 );
   attroff( A_REVERSE);
   attron( A_BOLD);
   color_set( 2,NULL);
   nodelay( stdscr, TRUE);

        nrclock_gameover =  0;
        while( nrclock_gameover == 0 ){

		time(&t);
		ltime=localtime(&t);
		sXmax = COLS;
		sYmax = LINES;

		if(sXmax/2<=sYmax)
			smax=sXmax/2;
		else
			smax=sYmax;

		hand_max = (smax/2)-1;

		sXcen = sXmax/2;
		sYcen = sYmax/2;

		erase();
		nrclock_drw_cir(hand_max, sYcen, sXcen);

		nrclock_draw_hand((ltime->tm_hour*5)+(ltime->tm_min/10), 2*hand_max/3, 'h', sXcen, sYcen);
		nrclock_draw_hand(ltime->tm_min, hand_max-2, 'm', sXcen, sYcen);
		nrclock_draw_hand(ltime->tm_sec, hand_max-1, '.', sXcen, sYcen);

		mvaddstr(sYcen-(3*hand_max/5), sXcen-5, ".:NRCLOCK:.");
		mvprintw(sYcen-(3*hand_max/5)   +1, sXcen-5    +2, ".:J-%d:.", 22 - ltime->tm_mday  );
		mvprintw(sYcen+(3*hand_max/5), sXcen-5, "[%02d:%02d:%02d]", ltime->tm_hour, ltime->tm_min, ltime->tm_sec);


  refresh();

     nodelay( stdscr, TRUE);
                ch = getch(); 
		switch( ch ){
		   case KEY_F(10):
		   case 'i':
		   case 'q':
		    nrclock_gameover = 1;
		    break;
		}

               usleep( 1e6 /2 /5 ); 
		// sleep(1);
	}
	// endwin();
   curs_set( 1 );
   attroff( A_REVERSE);
   color_set(0,NULL);
   nodelay( stdscr, FALSE);
}










void drawit(){
        int rows, cols;  
        getmaxyx( stdscr, rows, cols);
        mvprintw(5 , 5, "Hello World !!!");	
        mvprintw(rows-1 , 0, "<Press Key to Continue>");
}


int main()
{	
	initscr();	
        curs_set( 0 );

        drawit();
        nrclock();

	refresh();			
        curs_set( 1 );
	endwin();		
	return 0;
}





void ncrectangle( int y1, int x1, int y2, int x2 )
{
    int foo, fooy , foox ;
    for( fooy = y1 ; fooy <= y2 ; fooy++) 
    for( foo = x1 ; foo <= x2 ; foo++) 
         mvaddch( fooy , foo , ' ' );
}




void ncframe( int y1, int x1, int y2, int x2 )
{
    int foo, fooy , foox ;

    foo = x1;
    for( fooy = y1 ; fooy <= y2 ; fooy++) 
        mvaddch( fooy , foo , ACS_VLINE );

    foo = x2;
    for( fooy = y1 ; fooy <= y2 ; fooy++) 
         mvaddch( fooy , foo , ACS_VLINE );

    foo = y1;
    for( foox = x1 ; foox <= x2 ; foox++) 
         mvaddch( foo , foox , ACS_HLINE );

    foo = y2;
    for( foox = x1 ; foox <= x2 ; foox++) 
         mvaddch( foo , foox , ACS_HLINE );

    mvaddch( y1 , x1 , ACS_ULCORNER );
    mvaddch( y1 , x2 , ACS_URCORNER );
    mvaddch( y2 , x1 , ACS_LLCORNER );
    mvaddch( y2 , x2 , ACS_LRCORNER );
}
 
Old 07-12-2017, 03:33 PM   #6
chafporte
LQ Newbie
 
Registered: Jul 2017
Posts: 4

Rep: Reputation: Disabled
tiny file dialogs on sourceforge is a single C C++ cross-platform file which offers many modal dialogs including console dialogs. no init, no main loop, no linking.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Zenity help needed for dialog boxes please! BrokenWindows82 Linux - Software 4 04-20-2015 04:06 PM
Wine: No text in dialog boxes xTyphooNx Linux - Desktop 13 03-27-2007 08:38 AM
Wine: No text in dialog boxes xTyphooNx Linux - Desktop 1 09-05-2006 03:10 AM
Behave damn you! - dialog boxes Jeebizz Slackware 0 08-13-2006 02:06 AM
Firefox dying on dialog boxes Artanicus Linux - Software 1 02-22-2005 01:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration