예제 #1
0
파일: ut_seek.c 프로젝트: ngvrnd/urbit
  static u2_noun                                                  //  transfer
  _seek_silk(u2_wire wir_r, 
             u2_noun van,                                         //  retain
             u2_noun syx,                                         //  retain
             u2_noun tor)                                         //  retain
  {
    u2_noun p_tor, q_tor, pq_tor, qq_tor;
    u2_noun hey, ret;

    u2_as_cell(tor, &p_tor, &q_tor);
    if ( u2_yes == u2_h(q_tor) ) {
      return u2_nul;
    }
    u2_as_cell(u2_t(q_tor), &pq_tor, &qq_tor);
   
    hey = _seek_silk_yew(wir_r, van, syx, qq_tor);
    if ( u2_nul == hey ) {
      return u2_nul;
    }
    if ( u2_ckb_lent(u2_rx(wir_r, hey)) != 
         u2_ckb_lent(u2_rx(wir_r, qq_tor)) ) 
    {
      return u2_bl_error(wir_r, "silk");
    }

    ret = u2_bq
      (wir_r, u2_nul, 
              u2_no,
              j2_mbc(Pt3, peg)(wir_r, pq_tor, _seek_silk_yaw(wir_r, hey)),
              _seek_silk_fum(wir_r, hey, qq_tor));

    u2_rz(wir_r, hey);
    return ret;
  }
예제 #2
0
파일: term.c 프로젝트: gunnarahlberg/urbit
/* _term_ef_blit(): send blit to terminal.
*/
static void
_term_ef_blit(u2_utty* uty_u,
              u2_noun  blt)
{
  switch ( u2h(blt) ) {
    default: break;
    case c3__bel: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y);
      }
    } break;

    case c3__clr: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_blank(uty_u);
        _term_it_refresh_line(uty_u);
      }
    } break;

    case c3__hop: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_cursor(uty_u, u2t(blt));
      }
    } break;

    case c3__lin: {
      u2_noun lin = u2t(blt);
      c3_w    len_w = u2_ckb_lent(u2k(lin));
      c3_w*   lin_w = malloc(4 * len_w);

      {
        c3_w i_w;

        for ( i_w = 0; u2_nul != lin; i_w++, lin = u2t(lin) ) {
          lin_w[i_w] = u2_cr_word(0, u2h(lin));
        }
      }

      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_clear(uty_u);
        _term_it_show_line(uty_u, lin_w, len_w);
      } else {
        while ( uty_u->out_u ) {
          u2_ubuf* out_u = uty_u->out_u;
          uty_u->out_u = uty_u->out_u->nex_u;
          if ( 0 == uty_u->out_u ) {
            c3_assert(out_u == uty_u->tou_u);
            uty_u->tou_u = 0;
          }
          free(out_u);
        }
        _term_it_show_line(uty_u, lin_w, len_w);
      }
    } break;

    case c3__mor: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_more(uty_u);
      } else {
        _term_it_show_more(uty_u);
        _term_it_do_writes(uty_u);
      }
    } break;

    case c3__sav: {
      _term_it_save(u2k(u2h(u2t(blt))), u2k(u2t(u2t(blt))));
    } break;
  }
  u2z(blt);

  return;
}
/* _term_ef_blit(): send blit to terminal.
*/
static void
_term_ef_blit(u2_utty* uty_u,
              u2_noun  blt)
{
  switch ( u2h(blt) ) {
    default: break;
    case c3__bel: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y);
      }
    } break;

    case c3__clr: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_blank(uty_u);
        _term_it_refresh_line(uty_u);
      }
    } break;

    case c3__hop: {
      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_cursor(uty_u, u2t(blt));
      }
    } break;

    case c3__lin: {
      u2_noun lin = u2t(blt);
      c3_w    len_w = u2_ckb_lent(u2k(lin));
      c3_w*   lin_w = c3_malloc(4 * len_w);

      {
        c3_w i_w;

        for ( i_w = 0; u2_nul != lin; i_w++, lin = u2t(lin) ) {
          lin_w[i_w] = u2_cr_word(0, u2h(lin));
        }
      }

      if ( u2_no == u2_Host.ops_u.dem ) {
        _term_it_show_clear(uty_u);
        _term_it_show_line(uty_u, lin_w, len_w);
      } else {
        _term_it_show_line(uty_u, lin_w, len_w);
      }
    } break;

    case c3__mor: {
      _term_it_show_more(uty_u);
    } break;

    case c3__sav: {
      _term_it_save(u2k(u2h(u2t(blt))), u2k(u2t(u2t(blt))));
    } break;

    case c3__sag: {
      u2_noun pib = u2k(u2t(u2t(blt)));
      u2_noun jam;

      fprintf(stderr, "jamming...\r\n");
      jam = u2_cke_jam(pib);
      fprintf(stderr, "jammed.\r\n");

      _term_it_save(u2k(u2h(u2t(blt))), jam);
    } break;
  }
  u2z(blt);

  return;
}
예제 #4
0
파일: dash.c 프로젝트: MacTop/urbit
/* u2_ds_mine():
**
**   Register and/or save core.
*/
u2_noun                                                           //  transfer
u2_ds_mine(u2_wire wir_r,
           u2_noun clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_noun bas_r = u2_wire_bas_r(wir_r);

  if ( u2_no == u2_dust(cor) ) {
    return cor;
  } else {
    u2_noun pay = u2_t(cor);
    u2_noun bat = u2_h(cor);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat);
    u2_noun xip, bat_xip;
    u2_noun gop;

    if ( u2_none == pug ) {
      pug = u2_nul;
    }
    if ( u2_none == (xip = _ds_scan(pug, cor)) ) {
      gop = u2_rc(bas_r, (xip = _ds_chip(wir_r, clu, cor)), u2_rx(bas_r, pug));

      if ( u2_none == gop ) {
        return cor;
      } else {
        bat_xip = u2_h(u2_t(xip));

#if 0
        {
          c3_c* xip_c = u2_ho_cstring(xip);

          fprintf(stderr, "!%s - lent %d\r\n", xip_c, u2_ckb_lent(gop));
          free(xip_c);
        }
#endif
        gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop);
        {
          u2_noun poo = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat_xip);

          {
            _ds_scan(poo, cor);
          }
        }
        u2_rz(bas_r, gop);

      }
    }
    else {
      bat_xip = u2_h(u2_t(xip));
    }

    if ( bat_xip != bat ) {
      u2_noun cyr = u2_rc(wir_r, bat_xip, u2_rx(wir_r, pay));

      if ( u2_none == cyr ) {
        return cor;
      }
      else {
        u2_rz(wir_r, cor);
        return cyr;
      }
    }
    else return cor;
  }
}