Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - constant cvs_version="$Id: graphic_text.pike,v 1.155 1998/11/06 15:22:50 per Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.156 1998/11/18 04:54:15 per Exp $";   constant thread_safe=1;      #include <module.h>   #include <stat.h>   inherit "module";   inherit "roxenlib";      #ifndef VAR_MORE   #define VAR_MORE 0   #endif /* VAR_MORE */
Roxen.git/server/modules/graphics/graphic_text.pike:178:      object last_image; // Cache the last image for a while.   string last_image_name;   object load_image(string f,object id)   {    if(last_image_name == f && last_image) return last_image->copy();    string data;    object file;    object img;    -  if(!(data=roxen->try_get_file(fix_relative(f, id),id))) +  if(!(data=id->conf->try_get_file(f, id)))    if(!(file=open(f,"r")) || (!(data=file->read())))    return 0; - //werror("Read "+strlen(data)+" bytes.\n"); +  if(file) destruct(file);   #if constant(Image.GIF.decode)    catch { if(!img) img = Image.GIF.decode( data ); };   #endif   #if constant(Image.JPEG.decode)    catch { if(!img) img = Image.JPEG.decode( data ); };   #endif   #if constant(Image.PNG.decode)    catch { if(!img) img = Image.PNG.decode( data ); };   #endif - #if constant(Image.PNM.decode) +     catch { if(!img) img = Image.PNM.decode( data ); }; - #endif +     if(!img) return 0;    last_image = img; last_image_name = f;    return img->copy();   }      object blur(object img, int amnt)   {    img->setcolor(0,0,0);    img = img->autocrop(amnt, 0,0,0,0, 0,0,0);   
Roxen.git/server/modules/graphics/graphic_text.pike:697:    call_out(clean_cache_dir, 3600);   }      void start(int|void val, object|void conf)   {    loaded = 1;       if(conf)    {    mkdirhier( query( "cache_dir" )+"/.foo" ); - #ifndef __NT__ - #if efun(chmod) + #if constant(chmod)    // FIXME: Should this error be propagated?    catch { chmod( query( "cache_dir" ), 0777 ); };   #endif - #endif +     remove_call_out(clean_cache_dir);    call_out(clean_cache_dir, 10);    mc = conf;    base_key = "gtext:"+(conf?conf->name:roxen->current_configuration->name);    }   }      #ifdef QUANT_DEBUG   void print_colors(array from)   {
Roxen.git/server/modules/graphics/graphic_text.pike:746:   {    object fd = open(FNAME(a,b), "r");    if(!fd) return 0;    array r = decode_value(fd->read());    if(r[0]==a && r[1]==b) return r[2];   }      void store_cache_file(string a, string b, array data)   {    object fd = open(FNAME(a,b), "wct"); - #ifndef __NT__ - #if efun(chmod) + #if constant(chmod)    // FIXME: Should this error be propagated?    catch { chmod( FNAME(a,b), 0666 ); };   #endif - #endif +     if(!fd) return;    fd->write(encode_value(({a,b,data})));    destruct(fd);   }         array(int)|string write_text(int _args, string text, int size, object id)   {    string key = base_key+_args;    array err;
Roxen.git/server/modules/graphics/graphic_text.pike:862:    img = make_text_image(args,data,text,id);       // Now we have the image in 'img', or nothing.    if(!img) {   // werror("error while drawing image? (no image) < "+_args+" <"+text+">\n");   // cache_set(key, orig_text, 0);    return 0;    }      // Quantify -  int q = (int)args->quant||(args->background||args->texture?250:QUERY(cols)); +  int q=(int)args->quant||(args->background||args->texture?250:QUERY(cols));       if(q>255) q=255;    if(q<3) q=3;    - // if(!args->fs) - // img = img->map_closest(img->select_colors(q-1)+ - // ({parse_color(args->bg)})); +  if(!args->fs) +  img = img->map_closest(img->select_colors(q-1)+ +  ({parse_color(args->bg)}));       if(!args->scroll)    if(args->fadein)    {    int amount=2, steps=10, delay=10, initialdelay=0, ox;    string res = img->gif_begin();    sscanf(args->fadein,"%d,%d,%d,%d", amount, steps, delay, initialdelay);    if(initialdelay)    {    object foo=Image.image(img->xsize(),img->ysize(),@parse_color(args->bg));
Roxen.git/server/modules/graphics/graphic_text.pike:1056:      void save_cached_args()   {    int on;    on = number;    if(!args_restored) restore_cached_args();    if(on > number) number=on;    object o = open(ARGHASH, "wct");    if(o)    { - #ifndef __NT__ - #if efun(chmod) + #if constant(chmod)    // FIXME: Should this error be propagated?    catch { chmod( ARGHASH, 0666 ); };   #endif - #endif +     string data=encode_value(cached_args);    catch {    object q;    if(sizeof(indices(q=Gz)))    data=q->deflate()->deflate(data);    };    o->write(data);    }   }   
Roxen.git/server/modules/graphics/graphic_text.pike:1127:   {    if(!id->supports->netscape_javascript || !id->supports->images) return "";    return    ("\n<script>\n"    "function i(ri,hi,txt)\n"    "{\n"    " document.images[ri].src = hi.src;\n"    " setTimeout(\"top.window.status = '\"+txt+\"'\", 100);\n"    "}\n"    "</script>\n"); -  +    }         string magic_image(string url, int xs, int ys, string sn,    string image_1, string image_2, string alt, -  string mess,object id,string input,string extra_args,string lp) +  string mess,object id,string input, +  string extra_args,string lp)   {    if(!id->supports->images) return (lp?lp:"")+alt+(lp?"</a>":"");    if(!id->supports->netscape_javascript)    return (!input)?    ("<a "+extra_args+"href=\""+url+"\"><img src=\""+image_1+"\" name="+sn+" border=0 "+    "alt=\""+alt+"\"></a>"):    ("<input type=image "+extra_args+" src=\""+image_1+"\" name="+input+">");       return    ("<script>\n"
Roxen.git/server/modules/graphics/graphic_text.pike:1458:      string|array (string) tag_body(string t, mapping args, object id, object file,    mapping defines)   {    int cols,changed;    if(args->help) return "This tag is parsed by &lt;gtext&gt; to get the document colors.";    if(args->bgcolor||args->text||args->link||args->alink    ||args->background||args->vlink)    cols=1;    - #define FIX(Y,Z,X) do{if(!args->Y || args->Y==""){if(cols){defines->X=Z;args->Y=Z;changed=1;}}else{defines->X=args->Y;if(QUERY(colormode)&&args->Y[0]!='#'){args->Y=ns_color(parse_color(args->Y));changed=1;}}}while(0) + #define FIX(Y,Z,X) do{if(!args->Y || args->Y==""){if(cols){defines->X=Z;args->Y=Z;changed=1;}}else{defines->X=args->Y;catch{if(QUERY(colormode)&&args->Y[0]!='#'){args->Y=ns_color(parse_color(args->Y));changed=1;}};}}while(0)       if(!search((id->client||({}))*"","Mosaic"))    {    FIX(bgcolor,"#bfbfbf",bg);    FIX(text, "#000000",fg);    FIX(link, "#0000b0",link);    FIX(alink, "#3f0f7b",alink);    FIX(vlink, "#ff0000",vlink);    } else {    FIX(bgcolor,"#c0c0c0",bg);
Roxen.git/server/modules/graphics/graphic_text.pike:1505:   #undef FIX       if(changed && QUERY(colormode))    return ({ make_tag(tagname, args) });    return 0;   }      string|void pop_color(string tagname,mapping args,object id,object file,    mapping defines)   { -  if(args->help) return "This end-tag is parsed by &lt;gtext&gt; to get the document colors."; +  if(args->help) +  return "This end-tag is parsed by &lt;gtext&gt; to get the document colors.";    array c = id->misc->colors;    if(!c ||!sizeof(c))    return;       int i;    tagname = tagname[1..];       for(i=0;i<sizeof(c);i++)    if(c[-i-1][2]==tagname)    {    defines->fg = c[-i-1][0];    defines->bg = c[-i-1][1];    break;    } -  c = c[..sizeof(c)-i-2]; -  id->misc->colors = c; +  id->misc->colors = c[..sizeof(c)-i-2];   }      mapping query_tag_callers()   {    mapping tags = ([ "gtext-id":tag_gtext_id]);    if(query("colorparse"))    foreach(query("colorparsing"), string t)    {    switch(t)    {