⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coolinput.c

📁 具有IDE功能的编辑器
💻 C
字号:
/* coolinput.c - simple example usage of the coolwidget X API   Copyright (C) 1996-2000 Paul Sheer   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307, USA. */#include <coolwidget.h>#include "cmdlineopt.h"#include "pool.h"#include "mad.h"/* {{{ command-line options */#ifdef HAVE_DNDextern int option_dnd_version;#endif/* main and first window */Window main_window = 0;/* shell command to run */extern char *option_man_cmdline;/* argv[0] */char *argv_nought = 0;char *default_string = "";/* font from the library */extern char *init_font;/* server from command line */char *option_display = 0;/* font from the command line */char *option_font = "-*-helvetica-bold-r-*--14-*-*-*-p-*-*-*";static int get_help = 0;static int get_version = 0;/* other things on the command line */static char *command_line_args[] ={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};void usage (void){    printf (\	    _ ("Coolinput version %s\nUsage:\n" \	       "Coolinput [options] <Message-Header> <default_value> ...\n" \	       "-d, -display <display>                   the X server to display on\n" \	       "-f, -fn, -font <font-name>               default: 8x13bold\n" \	       "-h, -H, -?, --help                       print this message to stdout\n" \	       "-V, -v, --version                        print versiom info\n" \	       "Coolinput reads from stdin and makes an input box. Result is printed to stdout\n" \	       "\n"), \	    VERSION);}void version (void){    printf (_ ("Coolinput version %s\n"), VERSION);}struct prog_options coolinput_options[] ={    {' ', "", "", ARG_STRINGS, 0, command_line_args, 0},#ifdef HAVE_DND    {0, "-dnd-old", "--dnd-old", ARG_CLEAR, 0, 0, &option_dnd_version},#endif    {'f', "-fn", "-font", ARG_STRING, &option_font, 0, 0},    {'h', "-?", "--help", ARG_SET, 0, 0, &get_help},    {'H', "-help", "--help", ARG_SET, 0, 0, &get_help},    {'V', "-v", "--version", ARG_SET, 0, 0, &get_version},    {'d', "", "-display", ARG_STRING, &option_display, 0, 0},    {0, 0, 0, 0, 0, 0, 0}};/* here we use our own function (which is better than get_opt() or get_opt_long()) */static void process_command_line (int argc, char **argv){    int error;    error = get_cmdline_options (argc, argv, coolinput_options);    if (error) {	fprintf (stderr, _ ("%s: error processing commandline argument %d\n"), argv[0], error);	usage ();	exit (1);    }    if (get_help)	usage ();    if (get_version)	version ();    if (get_help || get_version)	exit (0);}/* }}} command-line options */void load_trivial_options (void);int main (int argc, char **argv){    POOL *p;    CInitData coolinput_startup;    char *header = 0, *r = 0;    setlocale (LC_CTYPE, "");    setlocale (LC_TIME, "");    setlocale (LC_MESSAGES, "");    bindtextdomain (PACKAGE, LOCALEDIR);    textdomain (PACKAGE);    load_trivial_options ();    process_command_line (argc, argv);/* initialise the library */    memset (&coolinput_startup, 0, sizeof (coolinput_startup));    coolinput_startup.name = argv[0];    coolinput_startup.display = option_display;    coolinput_startup.font = option_font;    CInitialise (&coolinput_startup);    CDrawMainWindow ("dummy", "dummy");    p = pool_init ();    for (;;) {	int c;	char ch;	c = fgetc (stdin);	if (c < 0)	    break;	ch = c;	pool_write (p, (unsigned char *) &c, 1);    }    pool_null (p);    if (!pool_length (p))	exit (0);    if (command_line_args[0] && command_line_args[1]) {	header = (char *) strdup (command_line_args[0]);	default_string = (char *) strdup (command_line_args[1]);    } else {	usage ();	CShutdown ();	exit (1);    }    r = CInputDialog ("input", CRoot, 20, 20, 200, default_string, header, "%s", pool_break (p));    if (!r)	printf ("-1\n");    else	printf ("%s\n", r);/* close connection to the X display */    CShutdown ();    exit (1);    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -