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

📄 config.c

📁 串口调试工具。非常好的串口调试助手
💻 C
📖 第 1 页 / 共 4 页
字号:
  else    string = g_strdup_printf("True");  cfgStoreValue(cfg, "crlfauto", string, CFG_INI, pos);  g_free(string);    string = g_strdup(term_conf.font);  cfgStoreValue(cfg, "font", string, CFG_INI, pos);  g_free(string);  macros = get_shortcuts(&size);  for(i = 0; i < size; i++)    {      string = g_strdup_printf("%s::%s", macros[i].shortcut, macros[i].action);      cfgStoreValue(cfg, "macros", string, CFG_INI, pos);      g_free(string);    }    if(term_conf.transparency == FALSE)    string = g_strdup_printf("False");  else    string = g_strdup_printf("True");  cfgStoreValue(cfg, "term_transparency", string, CFG_INI, pos);  g_free(string);  if(term_conf.show_cursor == FALSE)    string = g_strdup_printf("False");  else    string = g_strdup_printf("True");  cfgStoreValue(cfg, "term_show_cursor", string, CFG_INI, pos);  g_free(string);    string = g_strdup_printf("%d", term_conf.rows);  cfgStoreValue(cfg, "term_rows", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.columns);  cfgStoreValue(cfg, "term_columns", string, CFG_INI, pos);  g_free(string);    if(term_conf.visual_bell == FALSE)    string = g_strdup_printf("False");  else    string = g_strdup_printf("True");  cfgStoreValue(cfg, "term_visual_bell", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.foreground_color.red);  cfgStoreValue(cfg, "term_foreground_red", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.foreground_color.green);  cfgStoreValue(cfg, "term_foreground_green", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.foreground_color.blue);  cfgStoreValue(cfg, "term_foreground_blue", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.background_color.red);  cfgStoreValue(cfg, "term_background_red", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.background_color.green);  cfgStoreValue(cfg, "term_background_green", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%d", term_conf.background_color.blue);  cfgStoreValue(cfg, "term_background_blue", string, CFG_INI, pos);  g_free(string);  string = g_strdup_printf("%g", term_conf.background_saturation);  cfgStoreValue(cfg, "term_background_saturation", string, CFG_INI, pos);  g_free(string);  }gint remove_section(gchar *cfg_file, gchar *section){  FILE *f = NULL;  char *buffer = NULL;  char *buf;  long size;  gchar *to_search;  long i, j, length, sect;  f = fopen(cfg_file, "r");  if(f == NULL)    {      perror(cfg_file);      return -1;    }  fseek(f, 0L, SEEK_END);  size = ftell(f);  rewind(f);  buffer = g_malloc(size);  if(buffer == NULL)    {      perror("malloc");      return -1;    }  fread(buffer, 1, size, f);  fclose(f);  to_search = g_strdup_printf("[%s]", section);  length = strlen(to_search);  /* Search section */  for(i = 0; i < size - length; i++)    {      for(j = 0; j < length; j++)	{	  if(to_search[j] != buffer[i + j])	    break;	}      if(j == length)	break;    }    if(i == size - length)    {      i18n_printf(_("Cannot find section %s\n"), to_search);      return -1;    }  sect = i;  /* Search for next section */  for(i = sect + length; i < size; i++)    {      if(buffer[i] == '[')	break;    }  f = fopen(cfg_file, "w");  if(f == NULL)    {      perror(cfg_file);      return -1;    }  fwrite(buffer, 1, sect, f);  buf = buffer + i;   fwrite(buf, 1, size - i, f);  fclose(f);  g_free(to_search);  g_free(buffer);    return 0;}gint Config_Terminal(GtkWidget *widget, guint param){  GtkWidget *Dialog, *BoiteH, *BoiteV, *Label, *Check_Bouton, *Bouton, *Eventbox, *Table, *HScale;  gchar *fonte;  Dialog = gtk_dialog_new_with_buttons (_("Terminal configuration"),					NULL,					GTK_DIALOG_DESTROY_WITH_PARENT,					GTK_STOCK_CLOSE,					GTK_RESPONSE_CLOSE,					NULL);  gtk_widget_set_size_request(GTK_WIDGET(Dialog), 400, 300);  BoiteV = gtk_vbox_new(FALSE, 0);  gtk_container_set_border_width(GTK_CONTAINER(BoiteV), 10);  BoiteH = gtk_hbox_new(FALSE, 0);  Label = gtk_label_new(NULL);  gtk_label_set_markup(GTK_LABEL(Label), "<b>Font selection : </b>");  gtk_box_pack_start(GTK_BOX(BoiteH), Label, FALSE, TRUE, 0);  fonte =  g_strdup_printf("%s", term_conf.font);  Bouton_font = gtk_button_new_with_label(fonte);  gtk_box_pack_start(GTK_BOX(BoiteH), Bouton_font, FALSE, TRUE, 10);  g_signal_connect(GTK_OBJECT(Bouton_font), "clicked", G_CALLBACK(Config_Font), 0);  gtk_box_pack_start(GTK_BOX(BoiteV), BoiteH, FALSE, TRUE, 0);  Check_Bouton = gtk_check_button_new_with_label("Show cursor");  g_signal_connect(GTK_OBJECT(Check_Bouton), "toggled", G_CALLBACK(Curseur_OnOff), 0);  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Check_Bouton), term_conf.show_cursor);  gtk_box_pack_start(GTK_BOX(BoiteV), Check_Bouton, FALSE, TRUE, 5);  Label = gtk_label_new(NULL);  gtk_misc_set_alignment(GTK_MISC(Label), 0, 0);  gtk_label_set_markup(GTK_LABEL(Label), "<b>Colors : </b>");    gtk_box_pack_start(GTK_BOX(BoiteV), Label, FALSE, TRUE, 10);  Table = gtk_table_new(2, 2, FALSE);  Label = gtk_label_new("Text color :");  gtk_misc_set_alignment(GTK_MISC(Label), 0, 0);  gtk_table_attach(GTK_TABLE(Table), Label, 0, 1, 0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 10, 0);  Label = gtk_label_new("Background color :");  gtk_misc_set_alignment(GTK_MISC(Label), 0, 0);  gtk_table_attach(GTK_TABLE(Table), Label, 0, 1, 1, 2, GTK_SHRINK | GTK_FILL , GTK_SHRINK, 10, 0);  Bouton = gtk_button_new();  Eventbox = gtk_event_box_new();  gtk_container_add(GTK_CONTAINER(Bouton), Eventbox);  gtk_widget_set_size_request(GTK_WIDGET(Bouton), 60, 25);  gtk_widget_modify_bg(GTK_WIDGET(Eventbox), GTK_STATE_NORMAL, &term_conf.foreground_color);  gtk_table_attach(GTK_TABLE(Table), Bouton, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 10, 0);  g_signal_connect(GTK_OBJECT(Bouton), "clicked", G_CALLBACK(config_color_fg), Eventbox);  Bouton = gtk_button_new();  Eventbox = gtk_event_box_new();  gtk_container_add(GTK_CONTAINER(Bouton), Eventbox);  gtk_widget_set_size_request(GTK_WIDGET(Bouton), 60, 25);  gtk_widget_modify_bg(GTK_WIDGET(Eventbox), GTK_STATE_NORMAL, &term_conf.background_color);  gtk_table_attach(GTK_TABLE(Table), Bouton, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 10, 0);  g_signal_connect(GTK_OBJECT(Bouton), "clicked", G_CALLBACK(config_color_bg), Eventbox);  gtk_box_pack_start(GTK_BOX(BoiteV), Table, FALSE, TRUE, 0);  Label = gtk_label_new(NULL);  gtk_misc_set_alignment(GTK_MISC(Label), 0, 0);  gtk_label_set_markup(GTK_LABEL(Label), "<b>Transparency : </b>");    gtk_box_pack_start(GTK_BOX(BoiteV), Label, FALSE, TRUE, 10);  Check_Bouton = gtk_check_button_new_with_label("Transparency enable");  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Check_Bouton), term_conf.transparency);  gtk_box_pack_start(GTK_BOX(BoiteV), Check_Bouton, FALSE, TRUE, 0);  HScale = gtk_hscale_new_with_range(0.0, 100.0, 1.0);  gtk_range_set_value(GTK_RANGE(HScale), term_conf.background_saturation*100.0);  g_signal_connect(GTK_OBJECT(Check_Bouton), "toggled", G_CALLBACK(Transparency_OnOff), HScale);  g_signal_connect(GTK_RANGE(HScale), "value-changed", G_CALLBACK(change_scale), 0);  gtk_widget_set_sensitive(GTK_WIDGET(HScale), term_conf.transparency);  gtk_box_pack_start(GTK_BOX(BoiteV), HScale, FALSE, TRUE, 0);  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(Dialog)->vbox), BoiteV);  //g_signal_connect(GTK_OBJECT(Dialog), "response", G_CALLBACK(config_term_response), 0);  g_signal_connect_swapped(GTK_OBJECT(Dialog), "response", G_CALLBACK(gtk_widget_destroy), GTK_WIDGET(Dialog));    gtk_widget_show_all (Dialog);  return FALSE;}void Curseur_OnOff(GtkWidget *Check_Bouton, gpointer data){  term_conf.show_cursor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Check_Bouton));  }void Selec_couleur(GdkColor *Couleur, gfloat R, gfloat V, gfloat B){  Couleur->red=(guint16)(R*65535);  Couleur->green=(guint16)(V*65535);  Couleur->blue=(guint16)(B*65535);}gint config_color_fg(GtkWidget *bouton, gpointer data){  GtkWidget *Fenetre;  GtkColorSelection *colorsel;  gint response;  gchar *string;  Fenetre = gtk_color_selection_dialog_new ("Changing text color");  colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (Fenetre)->colorsel);        gtk_color_selection_set_previous_color (colorsel, &term_conf.foreground_color);  gtk_color_selection_set_current_color (colorsel, &term_conf.foreground_color);  gtk_color_selection_set_has_palette (colorsel, TRUE);  gtk_widget_set_size_request(GTK_WIDGET(Fenetre), 465, 315);  gtk_window_set_position(GTK_WINDOW(Fenetre), GTK_WIN_POS_CENTER);  response = gtk_dialog_run (GTK_DIALOG (Fenetre));  if (response == GTK_RESPONSE_OK)    {      gtk_color_selection_get_current_color (colorsel, &term_conf.foreground_color);      gtk_widget_modify_bg(GTK_WIDGET(data), GTK_STATE_NORMAL, &term_conf.foreground_color);      vte_terminal_set_color_foreground (VTE_TERMINAL(display), &term_conf.foreground_color);      gtk_widget_queue_draw(display);      string = g_strdup_printf("%d", term_conf.foreground_color.red);      cfgStoreValue(cfg, "term_foreground_red", string, CFG_INI, 0);      g_free(string);      string = g_strdup_printf("%d", term_conf.foreground_color.green);      cfgStoreValue(cfg, "term_foreground_green", string, CFG_INI, 0);      g_free(string);      string = g_strdup_printf("%d", term_conf.foreground_color.blue);      cfgStoreValue(cfg, "term_foreground_blue", string, CFG_INI, 0);      g_free(string);    }  gtk_widget_destroy(Fenetre);  return TRUE;}gint config_color_bg(GtkWidget *bouton, gpointer data){  GtkWidget *Fenetre;  GtkColorSelection *colorsel;  gint response;  gchar *string;  Fenetre = gtk_color_selection_dialog_new ("Changing background color");  colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (Fenetre)->colorsel);  gtk_color_selection_set_previous_color (colorsel, &term_conf.background_color);  gtk_color_selection_set_current_color (colorsel, &term_conf.background_color);    gtk_color_selection_set_has_palette (colorsel, TRUE);  gtk_widget_set_size_request(GTK_WIDGET(Fenetre), 465, 315);  gtk_window_set_position(GTK_WINDOW(Fenetre), GTK_WIN_POS_CENTER);  response = gtk_dialog_run (GTK_DIALOG (Fenetre));  if (response == GTK_RESPONSE_OK)    {      gtk_color_selection_get_current_color (colorsel, &term_conf.background_color);      gtk_widget_modify_bg(GTK_WIDGET(data), GTK_STATE_NORMAL, &term_conf.background_color);      vte_terminal_set_color_background (VTE_TERMINAL(display), &term_conf.background_color);      gtk_widget_queue_draw(display);      string = g_strdup_printf("%d", term_conf.background_color.red);      cfgStoreValue(cfg, "term_background_red", string, CFG_INI, 0);      g_free(string);      string = g_strdup_printf("%d", term_conf.background_color.green);      cfgStoreValue(cfg, "term_background_green", string, CFG_INI, 0);      g_free(string);      string = g_strdup_printf("%d", term_conf.background_color.blue);      cfgStoreValue(cfg, "term_background_blue", string, CFG_INI, 0);      g_free(string);          }  gtk_widget_destroy(Fenetre);  return TRUE;}static void Transparency_OnOff(GtkWidget *Check_Bouton, gpointer data){  gchar *string;  term_conf.transparency = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Check_Bouton));    vte_terminal_set_background_transparent(VTE_TERMINAL(display), term_conf.transparency);  gtk_widget_set_sensitive(GTK_WIDGET(data), term_conf.transparency);  if(term_conf.transparency == FALSE)    string = g_strdup_printf("False");  else    string = g_strdup_printf("True");    cfgStoreValue(cfg, "term_transparency", string, CFG_INI, 1);  g_free(string);}static void change_scale(GtkRange *range, gpointer data){  gchar *string;  term_conf.background_saturation = gtk_range_get_value(GTK_RANGE(range))/100.0;  vte_terminal_set_background_saturation(VTE_TERMINAL(display), (gdouble)term_conf.background_saturation);  string = g_strdup_printf("%g", term_conf.background_saturation);  cfgStoreValue(cfg, "term_background_saturation", string, CFG_INI, 0);  g_free(string);  }

⌨️ 快捷键说明

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