pure-data/src/g_editor.c

/* Copyright (c) 1997-2001 Miller Puckette and others.
 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
 * WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */

#include <stdio.h>
#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
#include "g_canvas.h"
#include "g_undo.h"
#include "s_utf8.h" /*-- moo --*/
#include <string.h>
#include "m_private_utils.h"


struct _instanceeditor
{};

    /* pointer to "globals" used in this Pd instance */
#define THISED

/* positional offset for duplicated items */
#define PASTE_OFFSET

void glist_readfrombinbuf(t_glist *x, const t_binbuf *b, const char *filename,
    int selectem);

/* ------------------ forward declarations --------------- */
static void canvas_doclear(t_canvas *x);
static void glist_setlastxy(t_glist *gl, int xval, int yval);
static void glist_donewloadbangs(t_glist *x);
static t_binbuf *canvas_docopy(t_canvas *x);
static void canvas_dopaste(t_canvas *x, t_binbuf *b);
static void canvas_paste(t_canvas *x);
static void canvas_clearline(t_canvas *x);
static t_glist *glist_finddirty(t_glist *x);
static void canvas_zoom(t_canvas *x, t_floatarg zoom);
static void canvas_displaceselection(t_canvas *x, int dx, int dy);
void canvas_setgraph(t_glist *x, int flag, int nogoprect);

/* ------------------------ managing the selection ----------------- */
void glist_deselectline(t_glist *x);

static void _editor_selectlinecolor(t_glist*x, const char*color)
{}
void glist_selectline(t_glist *x, t_outconnect *oc, int index1,
    int outno, int index2, int inno)
{}

void glist_deselectline(t_glist *x)
{}

int glist_isselected(t_glist *x, t_gobj *y)
{}

    /* call this for unselected objects only */
void glist_select(t_glist *x, t_gobj *y)
{}

    /* recursively deselect everything in a gobj "g", if it happens to be
       a glist, in preparation for deselecting g itself in glist_dselect() */
static void glist_checkanddeselectall(t_glist *gl, t_gobj *g)
{}

    /* call this for selected objects only */
void glist_deselect(t_glist *x, t_gobj *y)
{}

void glist_noselect(t_glist *x)
{}

void glist_selectall(t_glist *x)
{}

    /* get the index of a gobj in a glist.  If y is zero, return the
       total number of objects. */
int glist_getindex(t_glist *x, t_gobj *y)
{}

    /* get the index of the object, among selected items, if "selected"
       is set; otherwise, among unselected ones.  If y is zero, just
       counts the selected or unselected objects. */
int glist_selectionindex(t_glist *x, t_gobj *y, int selected)
{}

static t_gobj *glist_nth(t_glist *x, int n)
{}

t_rtext *glist_textedfor(t_glist *gl)
{}

void glist_settexted(t_glist *gl, t_rtext *x)
{}

/* ------------------- support for undo/redo  -------------------------- */

static void canvas_applybinbuf(t_canvas *x, t_binbuf *b)
{}


static int canvas_undo_confirmdiscard(t_gobj *g)
{}

void canvas_undo_set_name(const char*name)
{}

void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
    const char *name)
{}

    /* clear undo if it happens to be for the canvas x.
       (but if x is 0, clear it regardless of who owns it.) */
void canvas_noundo(t_canvas *x)
{}

    /* user hits "undo" in GUI */
static void canvas_undomenu(t_canvas *x)
{}

/* ------- specific undo methods: 1. connect -------- */
t_undo_connect;

void *canvas_undo_set_disconnect(t_canvas *x,
    int index1, int outno, int index2, int inno);

/* connect just calls disconnect actions backward... (see below) */
void *canvas_undo_set_connect(t_canvas *x,
    int index1, int outno, int index2, int inno)
{}

int canvas_undo_connect(t_canvas *x, void *z, int action)
{}

static void canvas_connect_with_undo(t_canvas *x,
    t_float index1, t_float outno, t_float index2, t_float inno)
{}

/* ------- specific undo methods: 2. disconnect -------- */

void *canvas_undo_set_disconnect(t_canvas *x,
    int index1, int outno, int index2, int inno)
{}

void canvas_disconnect(t_canvas *x,
    t_float index1, t_float outno, t_float index2, t_float inno)
{}

int canvas_undo_disconnect(t_canvas *x, void *z, int action)
{}

static void canvas_disconnect_with_undo(t_canvas *x,
    t_float index1, t_float outno, t_float index2, t_float inno)
{}

/* ---------- ... 3. cut, clear, and typing into objects: -------- */

#define UCUT_CUT
#define UCUT_CLEAR

/* following action is not needed any more LATER remove any signs of UCUT_TEXT
 * since recreate takes care of this in a more elegant way
 */
#define UCUT_TEXT

t_undo_cut;

void *canvas_undo_set_cut(t_canvas *x, int mode)
{}

int canvas_undo_cut(t_canvas *x, void *z, int action)
{}

/* --------- 4. motion, including "tidy up" and stretching ----------- */

t_undo_move_elem;

t_undo_move;

void *canvas_undo_set_move(t_canvas *x, int selected)
{}

int canvas_undo_move(t_canvas *x, void *z, int action)
{}

/* --------- 5. paste (also duplicate) ----------- */

t_undo_paste;

void *canvas_undo_set_paste(t_canvas *x, int numpasted, int duplicate,
    int d_offset)
{}
void *canvas_undo_set_pastebinbuf(t_canvas *x, t_binbuf *b,
    int numpasted, int duplicate, int d_offset)
{}


int canvas_undo_paste(t_canvas *x, void *z, int action)
{}

/* --------- 6. apply  ----------- */

t_undo_apply;

void *canvas_undo_set_apply(t_canvas *x, int n)
{}

static int canvas_apply_restore_original_position(t_canvas *x, int orig_pos);
int canvas_undo_apply(t_canvas *x, void *z, int action)
{}

int canvas_apply_restore_original_position(t_canvas *x, int orig_pos)
{}

/* --------- 7. arrange (to front/back)  ----------- */
t_undo_arrange;

void *canvas_undo_set_arrange(t_canvas *x, t_gobj *obj, int newindex)
{}

/* called by undo/redo arrange and done_canvas_popup. only done_canvas_popup
   checks if it is a valid action and activates undo option */
static void canvas_doarrange(t_canvas *x, t_float which, t_gobj *oldy,
    t_gobj *oldy_prev, t_gobj *oldy_next)
{}

int canvas_undo_arrange(t_canvas *x, void *z, int action)
{}

/* --------- 8. apply on canvas ----------- */
t_undo_canvas_properties;

void *canvas_undo_set_canvas(t_canvas *x)
{}

int canvas_undo_canvas_apply(t_canvas *x, void *z, int action)
{}
/* --------- 9. create ----------- */

t_undo_create;

void *canvas_undo_set_create(t_canvas *x)
{}

int canvas_undo_create(t_canvas *x, void *z, int action)
{}

/* ------ 10. recreate (called from text_setto after text has changed) ------ */

/* recreate uses t_undo_create struct */

void *canvas_undo_set_recreate(t_canvas *x, t_gobj *y, int pos)
{}

int canvas_undo_recreate(t_canvas *x, void *z, int action)
{}

/* ----------- 11. font -------------- */
static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize, t_floatarg yresize);

t_undo_font;

void *canvas_undo_set_font(t_canvas *x, int font, t_float resize, int which)
{}

int canvas_undo_font(t_canvas *x, void *z, int action)
{}

int clone_match(t_pd *z, t_symbol *name, t_symbol *dir);
static void canvas_cut(t_canvas *x);

    /* recursively check for abstractions to reload as result of a save.
       Don't reload the one we just saved ("except") though. */
    /* LATER try to do the same trick for externs. */
static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir,
    t_gobj *except)
{}

    /* call canvas_doreload on everyone */
void canvas_reload(t_symbol *name, t_symbol *dir, t_glist *except)
{}

/* ------------------------ event handling ------------------------ */

static const char *cursorlist[] =;

void canvas_setcursor(t_canvas *x, unsigned int cursornum)
{}

    /* check if a point lies in a gobj.  */
int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
    int *x1p, int *y1p, int *x2p, int *y2p)
{}

    /* find the last gobj, if any, containing the point. */
static t_gobj *canvas_findhitbox(t_canvas *x, int xpos, int ypos,
    int *x1p, int *y1p, int *x2p, int *y2p)
{}

/* -------------------  editors -------------------- */

static t_editor *editor_new(t_glist *owner)
{}

static void editor_free(t_editor *x, t_glist *y)
{}

    /* create an editor for the glist in preparation for making it visible */
void canvas_create_editor(t_glist *x)
{}

void canvas_destroy_editor(t_glist *x)
{}

void canvas_reflecttitle(t_canvas *x);
void canvas_map(t_canvas *x, t_floatarg f);

    /* we call this when we want the window to become visible, mapped, and
       in front of all windows; or with "f" zero, when we want to get rid of
       the window. */
void canvas_vis(t_canvas *x, t_floatarg f)
{}

    /* set a canvas up as a graph-on-parent.  Set reasonable defaults for
       any missing parameters and redraw things if necessary. */
void canvas_setgraph(t_glist *x, int flag, int nogoprect)
{}

void garray_properties(t_garray *x);

    /* tell GUI to create a properties dialog on the canvas.  We tell
       the user the negative of the "pixel" y scale to make it appear to grow
       naturally upward, whereas pixels grow downward. */
void canvas_properties(t_gobj*z, t_glist*unused)
{}

    /* called from the gui when "OK" is selected on the canvas properties
       dialog.  Again we negate "y" scale. */
static void canvas_donecanvasdialog(t_glist *x,
    t_symbol *s, int argc, t_atom *argv)
{}

    /* called from the gui when a popup menu comes back with "properties,"
       "open," or "help." */
static void canvas_done_popup(t_canvas *x, t_float which,
    t_float xpos, t_float ypos)
{}

#define NOMOD
#define SHIFTMOD
#define CTRLMOD
#define ALTMOD
#define RIGHTCLICK

#define DCLICKINTERVAL

    /* undarken deselected gatoms:
     * it's slightly ugly to have this in here,  but we cannot undarken
     * in gatom_key (which is the gatom's e_keyfn) as this is also called
     * when the user just hits <kbd>Enter</kbd>
     */
void gatom_undarken(t_text *x);
static void undarken_if_gatom(t_gobj *gobj)
{}

    /* right-clicking on a canvas object pops up a menu. */
static void canvas_rightclick(t_canvas *x, int xpos, int ypos, int mod)
{}

    /* mouse click or, if !doit, mouse motion (in which case we still search
    through the canvas to show the appropriate cursor) */
static void canvas_doclick(t_canvas *x, int xpix, int ypix, int mod, int doit)
{}

    /* mouse click or motion as a Pd message.  The 'which' arg
    is ignored but kept for back compatibility with anyone who might
    have reverse-engineered the GUI */
void canvas_mouse(t_canvas *x, t_floatarg xpix, t_floatarg ypix,
    t_floatarg which, t_floatarg mod)
{}

int canvas_isconnected (t_canvas *x, t_text *ob1, int n1,
    t_text *ob2, int n2)
{}

static int canconnect(t_canvas*x, t_object *src, int nout,
    t_object *sink, int nin)
{}

static int tryconnect(t_canvas*x, t_object *src, int nout,
    t_object *sink, int nin)
{}

static void canvas_doconnect(t_canvas *x, int xpos, int ypos, int mod, int doit)
{}

void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy)
{}

static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
{}

void canvas_mouseup(t_canvas *x,
    t_floatarg fxpos, t_floatarg fypos, t_floatarg fwhich,
    t_floatarg fmod)
{}

    /* displace the selection by (dx, dy) pixels */
static void canvas_displaceselection(t_canvas *x, int dx, int dy)
{}

    /* this routine is called whenever a key is pressed or released.  "x"
       may be zero if there's no current canvas.  The first argument is true or
       false for down/up; the second one is either a symbolic key name (e.g.,
       "Right" or an Ascii key number.  The third is the shift key. */
void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
{}

static void delay_move(t_canvas *x)
{}

    /* defined in g_text.c: */
extern void text_getfont(t_text *x, t_glist *thisglist,
    int *fwidthp, int *fheightp, int *guifsize);

void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
    t_floatarg fmod)
{}

void canvas_startmotion(t_canvas *x)
{}

/* ----------------------------- window stuff ----------------------- */
extern int sys_perf;

void canvas_print(t_canvas *x, t_symbol *s)
{}

    /* find the innermost dirty sub-glist, if any, of this one
        (including itself) */
static t_glist *glist_finddirty(t_glist *x)
{}

    /* quit, after calling glist_finddirty() on all toplevels and verifying
       the user really wants to discard changes  */
void glob_verifyquit(void *dummy, t_floatarg f)
{}

    /* close a window (or possibly quit Pd), checking for dirty flags.
       The "force" parameter is interpreted as follows:
       0 - request from GUI to close, verifying whether clean or dirty
       1 - request from GUI to close, no verification
       2 - verified - mark this one clean, then continue as in 1
       3 - verified - mark this one clean, then verify-and-quit
    */
void canvas_menuclose(t_canvas *x, t_floatarg fforce)
{}

    /* put up a dialog which may call canvas_font back to do the work */
static void canvas_menufont(t_canvas *x)
{}

t_zoomfn;

/* LATER, if canvas is flipped, re-scroll to preserve bottom left corner */
static void canvas_zoom(t_canvas *x, t_floatarg zoom)
{}

    /* function to support searching */
static int atoms_match(int inargc, t_atom *inargv, int searchargc,
    t_atom *searchargv, int wholeword)
{}

extern int clone_get_n(t_gobj *x);
extern t_glist *clone_get_instance(t_gobj *x, int n);

    /* find an atom or string of atoms */
static int canvas_dofind(t_canvas *x, int *myindexp)
{}

static void canvas_find(t_canvas *x, t_symbol *s, t_floatarg wholeword)
{}

static void canvas_find_again(t_canvas *x)
{}

static void canvas_find_parent(t_canvas *x)
{}

extern t_pd *message_get_responder(t_gobj *x);
extern t_class *text_class;

static int glist_dofinderror(t_glist *gl, const void *error_object)
{}

void canvas_finderror(const void *error_object)
{}

void canvas_stowconnections(t_canvas *x)
{}

void canvas_restoreconnections(t_canvas *x)
{}

static t_binbuf *canvas_docopy(t_canvas *x)
{}

static void canvas_copy(t_canvas *x)
{}

static void canvas_clearline(t_canvas *x)
{}

static void canvas_doclear(t_canvas *x)
{}

static void canvas_cut(t_canvas *x)
{}

static void glist_donewloadbangs(t_glist *x)
{}

static int binbuf_nextmess(int argc, const t_atom *argv)
{}
static int binbuf_getpos(t_binbuf*b, int *x0, int *y0, t_symbol**type)
{}

static void canvas_dopaste(t_canvas *x, t_binbuf *b)
{}

static t_symbol *get_object_type(t_object *obj)
{}

static void canvas_paste_replace(t_canvas *x)
{}


static void canvas_paste(t_canvas *x)
{}

static void canvas_duplicate(t_canvas *x)
{}

static void canvas_selectall(t_canvas *x)
{}

static void canvas_deselectall(t_canvas *x)
{}
static void canvas_cycleselect(t_canvas*x, t_float foffset)
{}


static void canvas_reselect(t_canvas *x)
{}

void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
    t_floatarg fwhoin, t_floatarg finno)
{}

#define XTOLERANCE
#define YTOLERANCE
#define NHIST

    /* LATER might have to speed this up */
static void canvas_tidy(t_canvas *x)
{}

/* returns the total number of connections between two objects
 * outno/inno are set to the last connection indices
 */
static int canvas_getconns(t_object*objsrc, int *outno, t_object*objsink, int *inno)
{}
static int canvas_try_bypassobj1(t_canvas* x,
    t_object* obj0, int in0, int out0,
    t_object* obj1, int in1, int out1,
    t_object* obj2, int in2, int out2)
{}
static int canvas_try_insert(t_canvas *x
    , t_object* obj00, int in00, int out00 /* source */
    , t_object* obj11, int in11, int out11 /* sink   */
    , t_object* obj22, int in22, int out22 /* insert */
    )
{}
    /* If we have two selected objects on the canvas, try to connect
       the first outlet of the upper object to the first inlet with
       a compatible type in the lower one. */
static void canvas_connect_selection(t_canvas *x)
{}

static void canvas_texteditor(t_canvas *x)
{}

void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av)
{}

void canvas_editmode(t_canvas *x, t_floatarg state)
{}

    /* called by canvas_font below */
static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize,
    t_floatarg yresize)
{}

    /* canvas_menufont calls up a TK dialog which calls this back */
static void canvas_font(t_canvas *x, t_floatarg font, t_floatarg resize,
    t_floatarg whichresize)
{}

void glist_getnextxy(t_glist *gl, int *xpix, int *ypix)
{}

static void glist_setlastxy(t_glist *gl, int xval, int yval)
{}


void canvas_triggerize(t_glist*cnv);

void g_editor_setup(void)
{}

void canvas_editor_for_class(t_class *c)
{}

void g_editor_newpdinstance(void)
{}

void g_editor_freepdinstance(void)
{}