⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dump-boundaries.c

📁 GTK+-2.0源码之pango-1.15.6.tar.gz
💻 C
字号:
/* Pango * dump-boundaries.c: Dump text boundaries for a file * * Copyright (C) 1999-2000 Red Hat Software * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */#include <string.h>#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <pango/pango.h>#define CHFORMAT "%0#6x"static void fail (const char *format, ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN;static void fail (const char *format, ...){  char *str;  va_list args;  va_start (args, format);  str = g_strdup_vprintf (format, args);  va_end (args);  fprintf (stderr, "Error: %s\n", str);  g_free (str);  exit (1);}static voiddump_text (const char *text){  int len;  PangoLogAttr *attrs;  int i;  gunichar *ucs4;  if (!g_utf8_validate (text, -1, NULL))    fail ("Invalid UTF-8 in file");  len = g_utf8_strlen (text, -1);  attrs = g_new0 (PangoLogAttr, len + 1);  pango_get_log_attrs (text,		       -1,		       0,		       pango_language_from_string ("C"),		       attrs,		       len + 1);  ucs4 = g_utf8_to_ucs4 (text, -1, NULL, NULL, NULL);  i = 0;  while (i <= len)    {      char buf[7] = { '\0', };      char *loc;      g_unichar_to_utf8 (ucs4[i], buf);      if (*buf == '\n')	loc = g_strdup ("\\n");      else if (*buf == '\r')	loc = g_strdup ("\\r");      else	loc = g_locale_from_utf8 (buf, -1, NULL, NULL, NULL);      g_print (CHFORMAT " (%s):\t line_break = %d mandatory_break = %d char_break = %d\n"	       "     \t\t white = %d cursor_position = %d\n"	       "     \t\t word_start = %d word_end = %d\n"	       "     \t\t sentence_boundary = %d sentence_start = %d sentence_end = %d\n",	       ucs4[i], loc ? loc : "?",	       attrs[i].is_line_break,	       attrs[i].is_mandatory_break,	       attrs[i].is_char_break,	       attrs[i].is_white,	       attrs[i].is_cursor_position,	       attrs[i].is_word_start,	       attrs[i].is_word_end,	       attrs[i].is_sentence_boundary,	       attrs[i].is_sentence_start,	       attrs[i].is_sentence_end);      g_free (loc);      ++i;    }  g_free (ucs4);  g_free (attrs);}intmain (int    argc,      char **argv){  gchar *text;  g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);  if (argc < 2)    fail ("must give a filename on the command line");  if (!g_file_get_contents (argv[1], &text, NULL, NULL))    fail ("Couldn't open sample text file");  dump_text (text);  g_free (text);  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -