示例#1
0
static void nc_sigwinch(int s)
/* SIGWINCH signal handler */
{
    mpdm_t v;

#ifdef NCURSES_VERSION
    /* Make sure that window size changes... */
    struct winsize ws;

    int fd = open("/dev/tty", O_RDWR);

    if (fd == -1)
        return;                 /* This should never have to happen! */

    if (ioctl(fd, TIOCGWINSZ, &ws) == 0)
        resizeterm(ws.ws_row, ws.ws_col);

    close(fd);
#else
    /* restart curses */
    /* ... */
#endif

    /* invalidate main window */
    clearok(stdscr, 1);
    refresh();

    /* re-set dimensions */
    v = mpdm_hget_s(mp, L"window");
    mpdm_hset_s(v, L"tx", MPDM_I(COLS));
    mpdm_hset_s(v, L"ty", MPDM_I(LINES));

    /* reattach */
    signal(SIGWINCH, nc_sigwinch);
}
示例#2
0
extern "C" int kde4_drv_detect(int *argc, char ***argv)
{
    mpdm_t drv;
    KCmdLineOptions opts;
    Display *x11_display;
    int n;

    for (n = 0; n < *argc; n++) {
        if (strcmp(argv[0][n], "-txt") == 0 ||
            strcmp(argv[0][n], "-h") == 0)
            return 0;
    }

    /* try connecting directly to the Xserver */
    if ((x11_display = XOpenDisplay((char *) NULL)) == NULL)
        return 0;

    KAboutData aboutData("mp", 0,
                         ki18n("Minimum Profit"), VERSION,
                         ki18n("A programmer's text editor"),
                         KAboutData::License_GPL,
                         ki18n("Copyright (c) 1991-2009 Angel Ortega"),
                         ki18n(""),
                         "http://triptico.com", "*****@*****.**");

    KCmdLineArgs::init(*argc, *argv, &aboutData);

    /* command line options should be inserted here (I don't like this) */
    opts.add("t {tag}",         ki18n("Edits the file where tag is defined"));
    opts.add("e {mpsl_code}",   ki18n("Executes MPSL code"));
    opts.add("f {mpsl_script}", ki18n("Executes MPSL script file"));
    opts.add("d {directory}",   ki18n("Sets working directory"));
    opts.add("x {file}",        ki18n("Open file in the hexadecimal viewer"));
    opts.add(" +NNN",           ki18n("Moves to line number NNN of last file"));
    opts.add("txt",             ki18n("Use text mode instead of GUI"));
    opts.add("+[file(s)]",      ki18n("Documents to open"));
    KCmdLineArgs::addCmdLineOptions(opts);

    /* this is where it crashes if no X server */
    app = new KApplication(x11_display);

    drv = mpdm_hset_s(mpdm_root(), L"mp_drv", MPDM_H(0));

    mpdm_hset_s(drv, L"id",         MPDM_LS(L"kde4"));
    mpdm_hset_s(drv, L"startup",    MPDM_X(kde4_drv_startup));

    return 1;
}
示例#3
0
/**
 * mpsl_error - Generates an error.
 * @err: the error message
 *
 * Generates an error. The @err error message is stored in the ERROR
 * mpsl variable and the mpsl_abort global flag is set, so no further
 * mpsl code can be executed until reset.
 */
mpdm_t mpsl_error(mpdm_t err)
{
    /* abort further execution */
    mpsl_abort = 1;

    /* set the error */
    return mpdm_hset_s(mpdm_root(), L"ERROR", err);
}
示例#4
0
/**
 * mpsl_argv - Fills the ARGV global array.
 * @argc: number of arguments
 * @argv: array of string values
 *
 * Fills the ARGV global MPSL array with an array of arguments. These
 * are usually the ones sent to main().
 */
void mpsl_argv(int argc, char *argv[])
{
    int n;
    mpdm_t ARGV;

    /* create the ARGV array */
    ARGV = mpdm_hset_s(mpdm_root(), L"ARGV", MPDM_A(0));

    for (n = 0; n < argc; n++)
        mpdm_push(ARGV, MPDM_MBS(argv[n]));
}
示例#5
0
static void set_local_symbols(mpdm_t s, mpdm_t v, mpdm_t l)
/* sets (or creates) a list of local symbols with a list of values */
{
    if (l != NULL) {
        mpdm_t h;

        mpdm_ref(s);
        mpdm_ref(v);
        mpdm_ref(l);

        /* gets the top local variable frame */
        h = mpdm_aget(l, -1);

        if (MPDM_IS_ARRAY(s) || MPDM_IS_ARRAY(v)) {
            int n;
            mpdm_t a;

            for (n = 0; n < mpdm_size(s); n++)
                mpdm_hset(h, mpdm_aget(s, n), mpdm_aget(v, n));

            if (n < mpdm_size(v)) {
                /* store the rest of arguments into _ */
                a = mpdm_hset_s(h, L"_", MPDM_A(0));

                for (; n < mpdm_size(v); n++)
                    mpdm_push(a, mpdm_aget(v, n));
            }
        }
        else
            mpdm_hset(h, s, v);

        mpdm_unref(l);
        mpdm_unref(v);
        mpdm_unref(s);
    }
}
示例#6
0
/**
 * mpsl_startup - Initializes MPSL.
 *
 * Initializes the Minimum Profit Scripting Language. Returns 0 if
 * everything went OK.
 */
int mpsl_startup(void)
{
    mpdm_t r;
    mpdm_t m;

    /* startup MPDM */
    mpdm_startup();

    r = mpdm_root();

    /* creates INC, unless already defined */
    if (mpdm_hget_s(r, L"INC") == NULL)
        mpdm_hset_s(r, L"INC", MPDM_A(0));

    /* the TRUE value */
    mpdm_hset_s(r, L"TRUE", MPDM_I(1));

    /* standard file descriptors */
    mpdm_hset_s(r, L"STDIN",    MPDM_F(stdin));
    mpdm_hset_s(r, L"STDOUT",   MPDM_F(stdout));
    mpdm_hset_s(r, L"STDERR",   MPDM_F(stderr));

    /* home and application directories */
    mpdm_hset_s(r, L"HOMEDIR",  mpdm_home_dir());
    mpdm_hset_s(r, L"APPDIR",   mpdm_app_dir());

    /* fill now the MPSL hash */
    m = MPDM_H(0);
    mpdm_hset_s(r, L"MPSL", m);

    /* store things there */
    mpdm_hset_s(m, L"VERSION",  MPDM_MBS(VERSION));
    mpdm_hset_s(m, L"OPCODE",   mpsl_build_opcodes());
    mpdm_hset_s(m, L"LC",       MPDM_H(0));
    mpdm_hset_s(m, L"CORE",     mpsl_build_funcs());

    mpdm_dump_1 = mpsl_dump_1;

    return 0;
}
示例#7
0
static void register_functions(void)
{
    mpdm_t drv;

    drv = mpdm_hget_s(mpdm_root(), L"mp_drv");
    mpdm_hset_s(drv, L"main_loop",   MPDM_X(kde4_drv_main_loop));
    mpdm_hset_s(drv, L"shutdown",    MPDM_X(kde4_drv_shutdown));
    mpdm_hset_s(drv, L"clip_to_sys", MPDM_X(kde4_drv_clip_to_sys));
    mpdm_hset_s(drv, L"sys_to_clip", MPDM_X(kde4_drv_sys_to_clip));
    mpdm_hset_s(drv, L"update_ui",   MPDM_X(kde4_drv_update_ui));
    mpdm_hset_s(drv, L"timer",       MPDM_X(kde4_drv_timer));
    mpdm_hset_s(drv, L"busy",        MPDM_X(kde4_drv_busy));
    mpdm_hset_s(drv, L"alert",       MPDM_X(kde4_drv_alert));
    mpdm_hset_s(drv, L"confirm",     MPDM_X(kde4_drv_confirm));
    mpdm_hset_s(drv, L"openfile",    MPDM_X(kde4_drv_openfile));
    mpdm_hset_s(drv, L"savefile",    MPDM_X(kde4_drv_savefile));
    mpdm_hset_s(drv, L"form",        MPDM_X(kde4_drv_form));
}