Exemple #1
0
/**
 * Output a comment to the column using indent_with_tabs and
 * indent_cmt_with_tabs as the rules.
 * base_col is the indent of the first line of the comment.
 * On the first line, column == base_col.
 * On subsequnet lines, column >= base_col.
 *
 * @param brace_col the brace-level indent of the comment
 * @param base_col  the indent of the start of the comment (multiline)
 * @param column    the column that we should end up in
 */
static void cmt_output_indent(int brace_col, int base_col, int column)
{
   int iwt;
   int tab_col;

   iwt = cpd.settings[UO_indent_cmt_with_tabs].b ? 2 :
         (cpd.settings[UO_indent_with_tabs].n ? 1 : 0);

   tab_col = (iwt == 0) ? 0 : ((iwt == 1) ? brace_col : base_col);

   //LOG_FMT(LSYS, "%s(brace=%d base=%d col=%d iwt=%d) tab=%d cur=%d\n",
   //        __func__, brace_col, base_col, column, iwt, tab_col, cpd.column);

   cpd.did_newline = 0;
   if ((iwt == 2) || ((cpd.column == 1) && (iwt == 1)))
   {
      /* tab out as far as possible and then use spaces */
      while (next_tab_column(cpd.column) <= tab_col)
      {
         add_text("\t");
      }
   }

   /* space out the rest */
   while (cpd.column < column)
   {
      add_text(" ");
   }
}
Exemple #2
0
int			try_connect(gchar **tab, gpointer data)
{
  int			port;
  int			sock;
  struct sockaddr_in	sin;
  t_supinfo		*supinfo;

  supinfo = (t_supinfo *)data;
  port = atoi(tab[2]);
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
      add_text("Socket error \n", data);
      return (0);
    }
  sin.sin_family = AF_INET;
  sin.sin_port = htons(port);
  sin.sin_addr.s_addr = inet_addr(tab[1]);
  if ((connect(sock , (struct sockaddr *)&sin, sizeof(struct sockaddr_in))) == -1)
    {
      add_text("Connexion error \n", data);
      return (0);
    }
  supinfo->info_cli->s = sock;
  send(supinfo->info_cli->s, "noname", strlen("noname"), 0);
  supinfo->info_cli->is_connected = 1;
  return (1);
}
Exemple #3
0
static void
showed_message_cb (GtrTab *tab, GtrMsg *msg, GtrContextPanel *panel)
{
  GtkTextBuffer *buffer;
  GtkTextIter iter;
  GtkTextTag *bold;

  /* Update current msg */
  panel->priv->current_msg = msg;

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
  gtk_text_buffer_set_text (buffer, "", 0);
  gtk_text_buffer_get_start_iter (buffer, &iter);

  /* Create the bold tag for headers */
  bold = gtk_text_buffer_create_tag (buffer, NULL, "weight", PANGO_WEIGHT_BOLD,
                                     "weight-set", TRUE, NULL);

  /* Add custom comments */
  add_notes (buffer, &iter, bold, msg);

  /* Extracted comments */
  add_text (buffer, bold, &iter, _("Extracted comments:"),
            gtr_msg_get_extracted_comments (msg));

  /* Context */
  add_text (buffer, bold, &iter, _("Context:"),
            gtr_msg_get_msgctxt (msg));

  /* Format */
  add_text (buffer, bold, &iter, _("Format:"),
            gtr_msg_get_format (msg));
}
void Dialog::add_ifactive(QString input)
{
    if (active == FIRST) add_text(ui->firstLineEdit, input);
    else if (active == SECOND) add_text(ui->secondLineEdit, input);
    else add_text(ui->thirdLineEdit, input);
    clear_focus();
}
Exemple #5
0
            void chat_app::send_message()
            {
                INVARIANT(_message);
                INVARIANT(_send);
                INVARIANT(_conversation);

                auto text = gui::convert(_message->text());

                ///don't send empty messages
                u::trim(text);
                if(text.empty()) return;

                //update gui
                _message->clear();
                auto self = _conversation->user_service()->user().info().name();
                add_text(make_message_str("blue", self, text));

                //send the message 
                _clock++;

                text_message tm;
                tm.text = text;
                tm.clock = _clock;

                send_all(tm.to_message());
                if(_conversation->contacts().list().empty()) add_text(make_message_str("red", "notice", "nobody here..."));
            }
Exemple #6
0
/*-----------------------------------------------------------------------------------*/
static void
show(char *text)
{
  add_text(text);
  add_text("\n");
  ctk_label_set_text(&telnetstatus, text);
  ctk_window_redraw(&telnetwindow);
}
Exemple #7
0
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
    size_t width = 800, height = 200;

    glutInit( &argc, argv );
    glutInitWindowSize( width, height );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    glutCreateWindow( "Glyph Cartoon" );
    glutReshapeFunc( reshape );
    glutDisplayFunc( display );
    glutKeyboardFunc( keyboard );

    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf( stderr, "Error: %s\n", glewGetErrorString(err) );
        exit( EXIT_FAILURE );
    }
    fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );

    atlas = texture_atlas_new( 1024, 1024, 1 );
    buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" ); 
    texture_font_t *font =
		texture_font_new_from_file( atlas, 128, "fonts/ObelixPro.ttf" );

    vec2 pen    = {{50, 50}};
    vec4 black  = {{0.0, 0.0, 0.0, 1.0}};
    vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
    vec4 orange1 = {{1.0, 0.9, 0.0, 1.0}};
    vec4 orange2 = {{1.0, 0.6, 0.0, 1.0}};


    font->outline_type = 2;
    font->outline_thickness = 7;
    add_text( buffer, font, L"Freetype GL", pen, black, black );

    font->outline_type = 2;
    font->outline_thickness = 5;
    add_text( buffer, font, L"Freetype GL", pen, yellow, yellow );

    font->outline_type = 1;
    font->outline_thickness = 3;
    add_text( buffer, font, L"Freetype GL", pen, black, black );

    font->outline_type = 0;
    font->outline_thickness = 0;
    add_text( buffer, font, L"Freetype GL", pen, orange1, orange2 );

    shader = shader_load("shaders/v3f-t2f-c4f.vert",
                         "shaders/v3f-t2f-c4f.frag");
    mat4_set_identity( &projection );
    mat4_set_identity( &model );
    mat4_set_identity( &view );

    glutMainLoop( );
    return 0;
}
Exemple #8
0
static void
RefreshResponses (ENCOUNTER_STATE *pES)
{
	COORD y;
	BYTE response, extra_y; // JMS_GFX
	SIZE leading;
	STAMP s;


	SetContext (SpaceContext);
	GetContextFontLeading (&leading);
	BatchGraphics ();

	DrawSISComWindow ();
	y = SLIDER_Y + SLIDER_HEIGHT + RES_SCALE(1); // JMS_GFX
	for (response = pES->top_response; response < pES->num_responses;
			++response)
	{
		extra_y = (response == pES->top_response ? 0 : IF_HD(22)); // JMS_GFX
		
		pES->response_list[response].response_text.baseline.x = TEXT_X_OFFS + RES_SCALE(8); // JMS_GFX
		pES->response_list[response].response_text.baseline.y = y + leading + extra_y; // JMS_GFX
		pES->response_list[response].response_text.align = ALIGN_LEFT;
		if (response == pES->cur_response)
			y = add_text (-1, &pES->response_list[response].response_text);
		else
			y = add_text (-2, &pES->response_list[response].response_text);
	}

	if (pES->top_response)
	{
		s.origin.y = SLIDER_Y + SLIDER_HEIGHT + 1;
		s.frame = SetAbsFrameIndex (ActivityFrame, 6);
	}
	else if (y > SIS_SCREEN_HEIGHT)
	{
		s.origin.y = SIS_SCREEN_HEIGHT - 2;
		s.frame = SetAbsFrameIndex (ActivityFrame, 7);
	}
	else
		s.frame = 0;
	if (s.frame)
	{
		RECT r;

		GetFrameRect (s.frame, &r);
		s.origin.x = SIS_SCREEN_WIDTH - r.extent.width - 1;
		DrawStamp (&s);
	}

	UnbatchGraphics ();
}
// ------------------------------------------------------------------- init ---
void init( void )
{
    atlas = texture_atlas_new( 512, 512, 1 );
    auto filename = "fonts/Vera.ttf";
    auto text = "A Quick Brown Fox Jumps Over The Lazy Dog 0123456789";
    buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
    vec2 pen = {0,0};
    auto black = vec4{1,1,1,1};
    auto font = texture_font_new_from_file( atlas, 48, filename );
    font->rendermode = RENDER_SIGNED_DISTANCE_FIELD;
    auto bbox = add_text( buffer, font, text, &black, &pen );
    size_t i;
    auto vertices = buffer->vertices;
    for( i=0; i< vector_size(vertices); ++i ) {
        auto vert = (vertex *) vector_get(vertices,i);
        vert->x -= (int)(bbox.x + bbox.width/2);
        vert->y -= (int)(bbox.y + bbox.height/2);
    }

    glGenTextures( 1, &atlas->id );
    glBindTexture( GL_TEXTURE_2D, atlas->id );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RED, atlas->width, atlas->height,
                  0, GL_RED, GL_UNSIGNED_BYTE, atlas->data );

    shader = shader_load( "shaders/distance-field-2v5.vert",
                          "shaders/distance-field-2v5.frag" );
    mat4_set_identity( &projection );
    mat4_set_identity( &model );
    mat4_set_identity( &view );
}
Exemple #10
0
void
add_url (swf_extractor * swf, int * error, char * string)
{
    dprintf ("[add_url : adding '%s']\n", string);

    add_text (error, &swf->urls, &swf->num_urls, &current_max_urls, string);
}
Exemple #11
0
void	do_connect(gchar *cmd, gpointer data)
{
  gchar	**tab;

  tab = wordtab(cmd);
  if (count_tab(tab) < 2)
    add_text("/server ip port \n", data);
  else
    {
      if (try_connect(tab, data))
	add_text("Connected succesfully \n", data);
      else
	add_text("Error while trying to connect \n", data);
    }
  free_tab(tab);
}
// ------------------------------------------------------------------- init ---
void init( void )
{
    size_t i;
    vec2 pen = {{0,0}};
    vec4 color = {{0,0,0,1}};

    atlas  = texture_atlas_new( 512, 512, 1 );
    font = texture_font_new_from_file( atlas, 12, "../media/fonts/VeraMono.ttf" );
    buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );

    pen.y = -font->descender;
    for( i=0; i<line_count; ++i )
    {
        pen.x = 10.0;
        add_text( buffer, font, text, &color, &pen );
        pen.y += font->height - font->linegap;
    }

    glClearColor( 1.0, 1.0, 1.0, 1.0 );
    glDisable( GL_DEPTH_TEST );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glEnable( GL_TEXTURE_2D );
    glEnable( GL_BLEND );

    shader = shader_load("../media/shaders/v3f-t2f-c4f.vert",
                         "../media/shaders/v3f-t2f-c4f.frag");
    mat4_set_identity( &projection );
    mat4_set_identity( &model );
    mat4_set_identity( &view );
}
Exemple #13
0
Datum
dbms_output_put(PG_FUNCTION_ARGS)
{
    if (buffer)
		add_text(PG_GETARG_TEXT_PP(0));
    PG_RETURN_VOID();
}
Exemple #14
0
static void
FeedbackPlayerPhrase (UNICODE *pStr)
{
	SetContext (SpaceContext);
	
	BatchGraphics ();
	DrawSISComWindow ();
	if (pStr[0])
	{
		TEXT ct;

		ct.baseline.x = SIS_SCREEN_WIDTH >> 1;
		ct.baseline.y = SLIDER_Y + SLIDER_HEIGHT + RES_SCALE(13); // JMS_GFX
		ct.align = ALIGN_CENTER;
		ct.CharCount = (COUNT)~0;

		ct.pStr = GAME_STRING (FEEDBACK_STRING_BASE);
				// "(In response to your statement)"
		SetContextForeGroundColor (COMM_RESPONSE_INTRO_TEXT_COLOR);
		font_DrawText (&ct);

		ct.baseline.y += RES_SCALE(16); // JMS_GFX
		SetContextForeGroundColor (COMM_FEEDBACK_TEXT_COLOR);
		ct.pStr = pStr;
		add_text (-4, &ct);
	}
	UnbatchGraphics ();
}
Exemple #15
0
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
    glutInit( &argc, argv );
    glutInitWindowSize( 800, 400 );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    glutCreateWindow( "Freetype OpenGL / vertex arrays" );
    glutReshapeFunc( reshape );
    glutDisplayFunc( display );
    glutKeyboardFunc( keyboard );

    size_t i;
    texture_font_t *font = 0;
    texture_atlas_t *atlas = texture_atlas_new( 512, 512, 1 );
    const char * filename = "./Vera.ttf";
    wchar_t *text = L"A Quick Brown Fox Jumps Over The Lazy Dog 0123456789";
    buffer = vertex_buffer_new( "v3f:t2f:c4f" ); 
    vec2 pen = {{0,0}};
    vec4 black = {{0,0,0,1}};

    for( i=7; i < 27; ++i)
    {
        font = texture_font_new( atlas, filename, i );
        pen.x = 0;
        pen.y -= font->height;
        texture_font_load_glyphs( font, text );
        add_text( buffer, font, text, &black, &pen );
        texture_font_delete( font );
    }

    glBindTexture( GL_TEXTURE_2D, atlas->id );
    glutMainLoop( );
    return 0;
}
Exemple #16
0
Fichier : util.c Projet : imp/slist
/*
 * []----
 * | add_targets -- add TargetName and TargetAddress to text argument
 * |
 * | Add targets which this initiator is allowed to see based on
 * | the access_list associated with a target. If a target doesn't
 * | have an access list then let everyone see it.
 * []----
 */
static Boolean_t
add_targets(iscsi_conn_t *c, char **text, int *text_length)
{
	tgt_node_t	*targ		= NULL;
	Boolean_t	rval		= True;
	char		*targ_name	= NULL;

	while ((rval == True) && ((targ = tgt_node_next_child(targets_config,
	    XML_ELEMENT_TARG, targ)) != NULL)) {

		if (check_access(targ, c->c_sess->s_i_name, False) == True) {

			if (tgt_find_value_str(targ, XML_ELEMENT_INAME,
			    &targ_name) == False) {
				rval = False;
				break;
			}
			queue_prt(c->c_mgmtq, Q_CONN_LOGIN,
			    "CON%x    %24s = %s\n", c->c_num, "TargetName",
			    targ_name);

			(void) add_text(text, text_length, "TargetName",
			    targ_name);
			free(targ_name);
			add_target_address(c, text, text_length, targ);
		}
	}
	return (rval);
}
Exemple #17
0
SHELL	void	BBS_add()
{
	char	buf[LN_buf+1];
	char	b_tel[12+1],b_time[11+1],b_host[6+1],b_name[46+1];

	msgout("電話番号を入力してください。");
	getstr(b_tel);

	if (*b_tel=='\0')
		{
		 msgout("登録中止します。");
		 return;
		}

	msgout("運営時間は?(リターンのみだと24hr運営)");
	getstr(b_time);

	msgout("ホストプログラムの種類は?(ex. RT-BBS,WWIV,RGWWIV等)");
	getstr(b_host);

	msgout("そのネットの名前を入力してください。");
	getstr(b_name);

	sprt(buf,nps(b_tel,12)," ",nps((*b_time=='\0'?"24hr":b_time),11)
		," ",nps(b_host,6)," ",nps(b_name,46),NULL);
	add_text("bbslist",buf);
}
Exemple #18
0
/*
char str_getc_esc(const char **s){
	if(*(*s)++ != '\\'){
		return (*s)[-1];
	}
	char ret = 0;
	switch(**s){
	case 'a':
		++*s;
		return '\a';
	case 'b':
		++*s;
		return '\b';
	case 'e':
		++*s;
		return '\e';
	case 'f':
		++*s;
		return '\f';
	case 'n':
		++*s;
		return '\n';
	case 'r':
		++*s;
		return '\r';
	case 't':
		++*s;
		return '\t';
	case 'v':
		++*s;
		return '\v';
	case 'x':
		++*s;
		if('0' <= **s && **s <= '9'){
			ret = (**s - '0') << 4;
		}else if('A' <= **s && **s <= 'F'){
			ret = (**s - 'A' + 10) << 4;
		}else if('a' <= **s && **s <= 'f'){
			ret = (**s - 'a' + 10) << 4;
		}else{
			return '\0';
		}
		++*s;
		if('0' <= **s && **s <= '9'){
			ret |= **s - '0';
		}else if('A' <= **s && **s <= 'F'){
			ret |= **s - 'A' + 10;
		}else if('a' <= **s && **s <= 'f'){
			ret |= **s - 'a' + 10;
		}else{
			return '\0';
		}
		++*s;
		return ret;
	default:
		if('0' <= **s && **s <= '7'){
			ret = (*(*s)++ - '0') << 6; 
		}else{
			return *(*s)++;
		}
		if('0' <= **s && **s <= '7'){
			ret |= (*(*s)++ - '0') << 3;
		}else{
			return '\0';
		}
		return ('0' <= **s && **s <= '7') ? ret | (*(*s)++ - '0') : '\0';
	}
}
*/
int read_charset_prefix(const char *a, ast *t, position *p){
	if(is_end(p)){
		return 0;
	}
	int found = 0;
	for(const char *s = a + 1; *s;){
		++s;
		if(s[-1] == '.'){
			if(*p->curr == *s++){
				found = 1;
				break;
			}
		}else if(*s++ > *p->curr){
			s++;
		}else if(*p->curr <= *s++){
			found = 1;
			break;
		}
	}
	if(found ^ (*a == '-')){
		add_text(t, p->curr, 1);
		++p->curr;
		return 1;
	}
	return 0;
}
Exemple #19
0
static void
place_text_x(int x, int y)
{
    canvas_leftbut_proc = null_proc;
    canvas_middlebut_proc = null_proc;
    canvas_rightbut_proc = null_proc;
    canvas_locmove_proc = null_proc;
    canvas_ref_proc = null_proc;
    adjust_pos(x, y, fix_x, fix_y, &x, &y);
    translate_text(new_t, x - fix_x, y - fix_y);
    if (return_proc == copy_selected) {
	add_text(new_t);
    } else {
	list_add_text(&objects.texts, new_t);
	clean_up();
	set_lastposition(fix_x, fix_y);
	set_newposition(x, y);
	set_action_object(F_MOVE, O_TEXT);
	set_latesttext(new_t);
	set_modifiedflag();
    }
    redisplay_text(new_t);
    /* turn back on all relevant markers */
    update_markers(new_objmask);
    (*return_proc) ();
    draw_mousefun_canvas();
}
Exemple #20
0
SHELL	void	sys_log(char *s)
{
	char	buf[LN_buf+1];

	sprt(buf,stredatime(getdatime())," ",s,NULL);
	add_text("syslog",buf);
}
// ------------------------------------------------------------------- main ---
int
main( int argc, char **argv )
{
    glutInit( &argc, argv );
    glutInitWindowSize( 800, 600 );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    glutCreateWindow( "Signed Distance Field" );
    glutReshapeFunc( reshape );
    glutDisplayFunc( display );
    glutKeyboardFunc( keyboard );
#ifndef __APPLE__
    glewExperimental = GL_TRUE;
    GLenum err = glewInit();
    if (GLEW_OK != err)
    {
        /* Problem: glewInit failed, something is seriously wrong. */
        fprintf( stderr, "Error: %s\n", glewGetErrorString(err) );
        exit( EXIT_FAILURE );
    }
    fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
    texture_font_t *font = 0;
    texture_atlas_t *atlas = texture_atlas_new( 512, 512, 1 );
    const char * filename = "fonts/Vera.ttf";
    wchar_t *text = L"A Quick Brown Fox Jumps Over The Lazy Dog 0123456789";
    buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
    vec2 pen = {{0,0}};
    vec4 black = {{1,1,1,1}};
    font = texture_font_new_from_file( atlas, 48, filename );
    vec4 bbox = add_text( buffer, font, text, &black, &pen );
    size_t i;
    vector_t * vertices = buffer->vertices;
    for( i=0; i< vector_size(vertices); ++i )
    {
        vertex_t * vertex = (vertex_t *) vector_get(vertices,i);
        vertex->x -= (int)(bbox.x + bbox.width/2);
        vertex->y -= (int)(bbox.y + bbox.height/2);
    }


    glBindTexture( GL_TEXTURE_2D, atlas->id );

    fprintf( stderr, "Generating distance map...\n" );
    unsigned char *map = make_distance_map(atlas->data, atlas->width, atlas->height);
    fprintf( stderr, "done !\n");

    memcpy( atlas->data, map, atlas->width*atlas->height*sizeof(unsigned char) );
    free(map);
    texture_atlas_upload( atlas );

    shader = shader_load( "shaders/distance-field-2.vert",
                          "shaders/distance-field-2.frag" );
    mat4_set_identity( &projection );
    mat4_set_identity( &model );
    mat4_set_identity( &view );

    glutMainLoop( );
    return 0;
}
Exemple #22
0
/* Generates and sends an error document */
void send_errorpage(request *r) {
  char *page = NULL;
  size_t len = 0;
  int fildes;
  char file[decimal_length(int) + 5 + 1];/* an int, .html, \0 */

  /* Look for a ready-made error document */
  snprintf(file, 9, "%d.html", r->status);
  if((fildes = open(file, O_RDONLY)) != -1) {/* file exists and is readable */
    close(fildes);
    /* set up the request structure */
    free(r->file);
    r->file = strdup(file);
    file_stuff(r);
    send_file(r);
    return;
  }

  /* Generate page */
  add_text(&page, &len, "<html><head><title>%d %s</title></head>\n", r->status,
           status_reason[r->status]);
  add_text(&page, &len, "<body><h1>%d %s</h1>\n", r->status,
           status_reason[r->status]);

  if(page_text[r->status]) 
    add_text(&page, &len, page_text[r->status]);
  else
    add_text(&page, &len, "See "
             "<a href=\"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\">"
             "this</a> for more information.");

  add_text(&page, &len, "\n</body></html>\n");

  /* And now send the page */
  free(r->content_type);
  r->content_type = strdup("text/html");

  r->encoding = IDENTITY;
  r->content_length = len;

  send_headers(r);
  send_str(r->fd, "\r\n");
  if(r->meth != HEAD) send(r->fd, page, len, 0);

  free(page);
}
Exemple #23
0
/*-----------------------------------------------------------------------------------*/
void
telnet_newdata(struct telnet_state *s, char *data, uint16_t len)
{
  petsciiconv_topetscii(data, len);
  data[len] = 0;
  add_text(data);
  ctk_window_redraw(&telnetwindow);
}
Exemple #24
0
/*-----------------------------------------------------------------------------------*/
void
telnet_sent(struct telnet_state *s)
{
  petsciiconv_topetscii(sendline, sizeof(sendline));
  scrollup();
  add_text(sendline);
  CTK_TEXTENTRY_CLEAR(&telnetlinetextentry);
  ctk_window_redraw(&telnetwindow);
}
void litehtml::el_before_after_base::add_function( const tstring& fnc, const tstring& params )
{
	int idx = value_index(fnc.c_str(), _t("attr;counter;url"));
	switch(idx)
	{
	// attr
	case 0:
		{
			tstring p_name = params;
			trim(p_name);
			lcase(p_name);
			element::ptr el_parent = parent();
			if (el_parent)
			{
				const tchar_t* attr_value = el_parent->get_attr(p_name.c_str());
				if (attr_value)
				{
					add_text(attr_value);
				}
			}
		}
		break;
	// counter
	case 1:
		break;
	// url
	case 2:
		{
			tstring p_url = params;
			trim(p_url);
			if(!p_url.empty())
			{
				if(p_url.at(0) == _t('\'') || p_url.at(0) == _t('\"'))
				{
					p_url.erase(0, 1);
				}
			}
			if(!p_url.empty())
			{
				if(p_url.at(p_url.length() - 1) == _t('\'') || p_url.at(p_url.length() - 1) == _t('\"'))
				{
					p_url.erase(p_url.length() - 1, 1);
				}
			}
			if(!p_url.empty())
			{
				element::ptr el = std::make_shared<el_image>(get_document());
				el->set_attr(_t("src"), p_url.c_str());
				el->set_attr(_t("style"), _t("display:inline-block"));
				el->set_tagName(_t("img"));
				appendChild(el);
				el->parse_attributes();
			}
		}
		break;
	}
}
void litehtml::el_before_after_base::add_style(const litehtml::style& st)
{
	html_tag::add_style(st);

	tstring content = get_style_property(_t("content"), false, _t(""));
	if(!content.empty())
	{
		int idx = value_index(content.c_str(), content_property_string);
		if(idx < 0)
		{
			tstring fnc;
			tstring::size_type i = 0;
			while(i < content.length() && i != tstring::npos)
			{
				if(content.at(i) == _t('"'))
				{
					fnc.clear();
					i++;
					tstring::size_type pos = content.find(_t('"'), i);
					tstring txt;
					if(pos == tstring::npos)
					{
						txt = content.substr(i);
						i = tstring::npos;
					} else
					{
						txt = content.substr(i, pos - i);
						i = pos + 1;
					}
					add_text(txt);
				} else if(content.at(i) == _t('('))
				{
					i++;
					litehtml::trim(fnc);
					litehtml::lcase(fnc);
					tstring::size_type pos = content.find(_t(')'), i);
					tstring params;
					if(pos == tstring::npos)
					{
						params = content.substr(i);
						i = tstring::npos;
					} else
					{
						params = content.substr(i, pos - i);
						i = pos + 1;
					}
					add_function(fnc, params);
					fnc.clear();
				} else
				{
					fnc += content.at(i);
					i++;
				}
			}
		}
	}
}
Exemple #27
0
void RichTextLabel::set_bbcode(const String& p_bbcode) {
	bbcode=p_bbcode;
	if (is_inside_tree() && use_bbcode)
		parse_bbcode(p_bbcode);
	else { // raw text
		clear();
		add_text(p_bbcode);
	}
}
Exemple #28
0
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
    size_t width = 600, height = 200;

    glutInit( &argc, argv );
    glutInitWindowSize( width, height );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    glutCreateWindow( "Glyph Cartoon" );
    glutReshapeFunc( reshape );
    glutDisplayFunc( display );
    glutKeyboardFunc( keyboard );

    atlas = texture_atlas_new( 1024, 1024, 1 );
    buffer = vertex_buffer_new( "v3f:t2f:c4f" ); 
    texture_font_t *font = texture_font_new( atlas, "./ObelixPro.ttf", 128 );

    vec2 pen    = {{30, 50}};
    vec4 black  = {{0.0, 0.0, 0.0, 1.0}};
    vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
    vec4 orange1 = {{1.0, 0.9, 0.0, 1.0}};
    vec4 orange2 = {{1.0, 0.6, 0.0, 1.0}};


    font->outline_type = 1;
    font->outline_thickness = 4;
    add_text( buffer, font, L"Cartoon", pen, black, black );

/*
    font->outline_type = 2;
    font->outline_thickness = 4;
    add_text( buffer, font, L"Cartoon", pen, black, yellow );

    font->outline_type = 3;
    font->outline_thickness = 4;
    add_text( buffer, font, L"Cartoon", pen, black, yellow );

*/
    font->outline_type = 0;
    font->outline_thickness = 0;
    add_text( buffer, font, L"Cartoon", pen, orange1, orange2 );

    glutMainLoop( );
    return 0;
}
Exemple #29
0
// ------------------------------------------------------------------- init ---
void init( void )
{
    atlas = texture_atlas_new( 1024, 1024, 1 );
    buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
    texture_font_t *font =
    texture_font_new_from_file( atlas, 128, "fonts/LuckiestGuy.ttf" );

    vec2 pen    = {{50, 50}};
    vec4 black  = {{0.0, 0.0, 0.0, 1.0}};
    vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
    vec4 orange1 = {{1.0, 0.9, 0.0, 1.0}};
    vec4 orange2 = {{1.0, 0.6, 0.0, 1.0}};

    font->rendermode = RENDER_OUTLINE_POSITIVE;
    font->outline_thickness = 7;
    add_text( buffer, font, "Freetype GL", pen, black, black );

    font->rendermode = RENDER_OUTLINE_POSITIVE;
    font->outline_thickness = 5;
    add_text( buffer, font, "Freetype GL", pen, yellow, yellow );

    font->rendermode = RENDER_OUTLINE_EDGE;
    font->outline_thickness = 3;
    add_text( buffer, font, "Freetype GL", pen, black, black );

    font->rendermode = RENDER_NORMAL;
    font->outline_thickness = 0;
    add_text( buffer, font, "Freetype GL", pen, orange1, orange2 );

    glGenTextures( 1, &atlas->id );
    glBindTexture( GL_TEXTURE_2D, atlas->id );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RED, atlas->width, atlas->height,
                  0, GL_RED, GL_UNSIGNED_BYTE, atlas->data );

    shader = shader_load("shaders/v3f-t2f-c4f.vert",
                         "shaders/v3f-t2f-c4f.frag");
    mat4_set_identity( &projection );
    mat4_set_identity( &model );
    mat4_set_identity( &view );
}
Exemple #30
0
    void stream(Turns const& turns, Turn const& turn, Operation const& op, const std::string& header, const std::string& style)
    {
        std::ostringstream out;
        out << m_traverse_seq++ << " " << header
            << " " << stream_turn_index(turns, turn, op);

        out << " " << bg::visited_char(op.visited);

        add_text(turn, out.str(), style);
    }