Exemple #1
0
void mod_metadata_callback(GPid pid, gint status, gpointer data)
{
  int * out_fd = (int *)data;
  GString * msg = NULL;
  mod_t * mod = mods + mod_count;
  GtkTreeIter iter, mod_iter;

  mod_count = (mod_count + 1) % MAX_NUM_MODS;

  free_mod(mod);
  memset(mod, 0, sizeof(mod_t));

  msg = util_get_output(*out_fd);

  close(*out_fd);
  free(out_fd);

  if (!msg)
    return;

  process_lines(msg, mod_metadata_line, mod);

  g_string_free(msg, TRUE);

  gtk_tree_model_get_iter_first(GTK_TREE_MODEL(tree_store), &mod_iter);

  if (mod->standalone)
  {
    gtk_tree_store_append(tree_store, &iter, &mod_iter);
    gtk_tree_store_set(tree_store, &iter,
		       ICON_COLUMN, generic_mod_icon,
		       KEY_COLUMN, mod->key,
		       NAME_COLUMN, mod->title,
		       -1);
  }
  else if (!strlen(mod->requires))
  {
    GtkTreeIter broken_mods_iter;
    if (!gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(tree_store), 
					     &broken_mods_iter, "1"))
    {
      gtk_tree_store_append(tree_store, &broken_mods_iter, NULL);
    }
    gtk_tree_store_set(tree_store, &broken_mods_iter,
		       ICON_COLUMN, generic_mod_icon,
		       KEY_COLUMN, mod->key,
		       NAME_COLUMN, mod->title,
		       -1);
  }
  else
  {
    gtk_tree_model_foreach(GTK_TREE_MODEL(tree_store), append_to_mod, mod);
  }
}
Exemple #2
0
void process_root(struct ast_node_root* root, list_t* symbols)
{
    // Associate the global symbols variable.
    assem_dbg_symbols = symbols;

    // Process all of the lines.
    process_lines(root->values);

    // Reset the global symbols variable.
    assem_dbg_symbols = NULL;
}
Exemple #3
0
/*
 * Archive names specified in file.
 *
 * Unless --null was specified, a line containing exactly "-C" will
 * cause the next line to be a directory to pass to chdir().  If
 * --null is specified, then a line "-C" is just another filename.
 */
void
archive_names_from_file(struct bsdtar *bsdtar, struct archive *a)
{
	bsdtar->archive = a;

	bsdtar->next_line_is_dir = 0;
	process_lines(bsdtar, bsdtar->names_from_file,
	    archive_names_from_file_helper, bsdtar->option_null);
	if (bsdtar->next_line_is_dir)
		bsdtar_errc(bsdtar, 1, errno,
		    "Unexpected end of filename list; "
		    "directory expected after -C");
}
Exemple #4
0
  void param_set_notify(const vsx_string<>& name)
  {
    if (!declare_run)
      return;

    if (name == "font_in" || name == "glyph_size")
    {
      setup_font();
      if (ftfont)
      {
        process_lines();
      }
    }
  }
void vsx_widget_base_edit::set_string(const vsx_string& str) {
  lines.clear();
  vsx_string deli = "\n";
  vsx_string f = str_replace("\r","",str);
  explode(f, deli, lines);
  lines_visible.clear();
  for (unsigned long i = 0; i < lines.size(); i++) lines_visible.push_back(0);
  longest_line = 0;
  scrollbar_pos_x = 0;
  scrollbar_pos_y = 0;
  for (std::vector<vsx_string>::iterator it = lines.begin(); it != lines.end(); ++it) {
    if ((*it).size() > longest_line) longest_line = (*it).size();
  }
  // hide eventual action buttons
  for (size_t i = 0; i < action_buttons.size(); i++)
  {
    action_buttons[i]->visible = 0.0f;
  }
  process_lines();
  calculate_scroll_size();
}
Exemple #6
0
void mod_list_callback(GPid pid, gint status, gpointer data)
{
  callback_data * d = (callback_data *)data;
  GString * msg = NULL;
  
  msg = util_get_output(d->output_fd);

  close(d->output_fd);
  g_free(d);

  if (!msg)
    return;

  mod_count = 0;

  process_lines(msg, mod_list_line, NULL);

  util_get_setting("Game.Mods", last_mod_callback);

  g_string_free(msg, TRUE);
  
  g_spawn_close_pid(pid);
}
Exemple #7
0
/* Process options from the specified file, if it exists. */
static void
configfile(struct bsdtar *bsdtar, const char *fname)
{
	struct stat sb;

	/*
	 * If we had --no-config-exclude (or --no-config-include) earlier,
	 * we do not want to process any --exclude (or --include) options
	 * from now onwards.
	 */
	bsdtar->option_no_config_exclude_set =
	    bsdtar->option_no_config_exclude;
	bsdtar->option_no_config_include_set =
	    bsdtar->option_no_config_include;

	/* If the file doesn't exist, do nothing. */
	if (stat(fname, &sb)) {
		if (errno == ENOENT)
			return;

		/*
		 * Something bad happened.  Note that this could occur if
		 * there is no configuration file and part of the path to
		 * where we're looking for a configuration file exists and
		 * is a non-directory (e.g., if /usr/local/etc is a file);
		 * we're going to error out if this happens, since reporting
		 * a spurious error in such an odd circumstance is better
		 * than failing to report an error if there really is a
		 * configuration file.
		 */
		bsdtar_errc(bsdtar, 1, errno, "stat(%s)", fname);
	}

	/* Process the file. */
	process_lines(bsdtar, fname, configfile_helper, 0);
}
Exemple #8
0
int
exclude_from_file(struct bsdtar *bsdtar, const char *pathname)
{
	return (process_lines(bsdtar, pathname, &exclude,
	    bsdtar->option_null));
}
Exemple #9
0
void process_root(struct ast_node_root* root)
{
	// Process all of the lines.
	process_lines(root->values);
}
bool vsx_widget_base_edit::event_key_down(signed long key, bool alt, bool ctrl, bool shift) {
  if (!editing_enabled) return true;
  std::vector<vsx_string>::iterator it = lines.begin();
  std::vector<int>::iterator itlv = lines_visible.begin();

  std::vector<vsx_string>::iterator itp = lines_p.begin();
  int c2 = 0;
  scroll_x = floor(scroll_x);
  vsx_string tempstring;
  vsx_string tempstring2;
  //printf("key: %d\n",key);
  if (ctrl && !alt && !shift) {
    //printf("ctrl! %d\n",key);
    switch(key) {
      case 10:
        //save();
      break;
      case 'v':
      case 'V':
#ifdef _WIN32
        HANDLE hData;

        LPVOID pData;
        char* pszData = 0;
        HWND hwnd = GetForegroundWindow();
        if (!IsClipboardFormatAvailable(CF_TEXT)) return false;
        OpenClipboard(hwnd);
        hData = GetClipboardData(CF_TEXT);
        pData = GlobalLock(hData);
        if (pszData) free(pszData);
        pszData = (char*)malloc(strlen((char*)pData) + 1);
        strcpy(pszData, (LPSTR)pData);
        vsx_string res = pszData;
        GlobalUnlock(hData);
        CloseClipboard();
        res = str_replace("\n","",res);
        process_characters = false;
        for (int i = 0; i < res.size(); ++i) {
          event_key_down(res[i],false,false,false);
        }
        free(pszData);
        process_characters = true;
        process_lines();
// copying
/*HGLOBAL hData;
    LPVOID pData;
    OpenClipboard(hwnd);
    EmptyClipboard();
    hData = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE,
                        strlen(pszData) + 1);
    pData = GlobalLock(hData);
    strcpy((LPSTR)pData, pszData);
    GlobalUnlock(hData);
    SetClipboardData(CF_TEXT, hData);
    CloseClipboard();*/
#endif
      break;
    }
  } else
  switch(key) {
    // arrow left
    case -GLFW_KEY_LEFT:
      --caretx;
      if (caretx < 0) {
        if (scroll_x) {
          ++caretx;
          --scroll_x;
          //fix_pos();
        } else
        if (carety) {
          --carety;
        event_key_down(-GLFW_KEY_END);
        } else caretx = 0;
      }
      break;
    // arrow right
    case -GLFW_KEY_RIGHT:
      ++caretx;
      if ((size_t)caretx > lines[carety+(int)scroll_y].size()-(int)scroll_x) {
        event_key_down(-GLFW_KEY_DOWN);
        event_key_down(-GLFW_KEY_HOME);
      }
      if (caretx > characters_width-3) {
        --caretx;
        ++scroll_x;
      }
      break;
    // arrow up
    case -GLFW_KEY_UP:
      if (!single_row) {
        --carety;
        if (carety < 0) {
          carety = 0;
          if (scroll_y) {
            --scroll_y;
            //fix_pos();
          }
        }
        if ((size_t)caretx > lines[carety+(int)scroll_y].size()-(int)scroll_x)
        event_key_down(-GLFW_KEY_END);
         //caretx = lines[carety+(int)scroll_y].size()-(int)scroll_x;
        }
      break;
    // page up
    case -GLFW_KEY_PAGEUP:
      if (!single_row) {
        for (int zz = 0; zz < characters_height*0.95; ++zz) {
        event_key_down(-GLFW_KEY_UP);
        }
      }
      break;
    // arrow down
    case -GLFW_KEY_DOWN:
      if (!single_row) {
        ++carety;
        if (carety > lines.size()-1-scroll_y) carety = (int)((float)lines.size()-1.0f-scroll_y);
        if (carety > characters_height-2) {
          ++scroll_y;
          --carety;
        }
        if ((size_t)caretx > lines[carety+(int)scroll_y].size()-(int)scroll_x)
         caretx = lines[carety+(int)scroll_y].size()-(int)scroll_x;
      }
      break;
    // page down
    case -GLFW_KEY_PAGEDOWN:
      if (!single_row) {
        for (int zz = 0; zz < characters_height*0.95; ++zz) {
        event_key_down(-GLFW_KEY_DOWN,false,false,false);
        }
      }
      break;
    // home
    case -GLFW_KEY_HOME:
      scroll_x = 0;
      caretx = 0;
      //fix_pos();
      break;
    // end
    case -GLFW_KEY_END:
      caretx = lines[carety+(int)scroll_y].size()-(int)scroll_x;
      //if (caretx < 0) caretx = 0;
      if (caretx > characters_width-3) {
        scroll_x += caretx - characters_width+3;
        //fix_pos();
        caretx = (int)characters_width-3;
      }
      if (caretx < 0) {
        scroll_x += caretx-5;//lines[carety+(int)scroll_y].size()-5;
        if (scroll_x < 0) scroll_x = 0;
        caretx = lines[carety+(int)scroll_y].size()-(int)scroll_x;
      }
      //fix_pos();
    break;
    // backspace
    case -GLFW_KEY_BACKSPACE:
      if (caretx+(int)scroll_x) {
        lines[carety+(int)scroll_y].erase(caretx-1+(int)scroll_x,1);
        --caretx;
        if (caretx < 0) {--scroll_x; ++caretx;}
        process_line(carety+(int)scroll_y);
        //fix_pos();
      } else {
        if (scroll_y+carety) {
          while (c2 < carety+scroll_y) { ++c2; ++it; ++itp; ++itlv; }
          //++it;
          tempstring = lines[carety+(int)scroll_y];
          lines.erase(it);
          lines_p.erase(itp);
          lines_visible.erase(itlv);
        event_key_down(-GLFW_KEY_UP,false,false,false);
        event_key_down(-GLFW_KEY_END,false,false,false);
          lines[carety+(int)scroll_y] += tempstring;
          lines_p[carety+(int)scroll_y] += tempstring;
          process_line(carety+(int)scroll_y);
          process_line(carety+(int)scroll_y+1);
          //fix_pos();
        }
      }
      if (mirror_keystrokes_object) mirror_keystrokes_object->event_key_down(key, alt, ctrl, shift);
    break;
    // delete
    case -GLFW_KEY_DEL:
      event_key_down(-GLFW_KEY_RIGHT,false,false,false);
      event_key_down(-GLFW_KEY_BACKSPACE,false,false,false);
      process_line(carety+(int)scroll_y);
      if (mirror_keystrokes_object) mirror_keystrokes_object->event_key_down(key, alt, ctrl, shift);
    break;
    // enter
    case -GLFW_KEY_ENTER:
      if (single_row) {
        vsx_string d;
        if (command_prefix.size()) d = command_prefix+" ";
        command_q_b.add_raw(d+lines[0]);
        parent->vsx_command_queue_b(this);
      } else {
        if ((size_t)caretx+(size_t)scroll_x > lines[carety+(int)scroll_y].size()) event_key_down(-35,false,false,false);
        while (c2 < carety+(int)scroll_y) { ++c2; ++it; ++itp; ++itlv; }
        ++it;
        ++itp;
        ++itlv;
        tempstring = lines[carety+(int)scroll_y].substr(caretx+(int)scroll_x,lines[carety+(int)scroll_y].size()-(caretx+(int)scroll_x));
        tempstring2 = lines[carety+(int)scroll_y].substr(0,caretx+(int)scroll_x);
        lines[carety+(int)scroll_y] = tempstring2;
        lines.insert(it,tempstring);
        lines_visible.insert(itlv,0);

        tempstring = lines_p[carety+(int)scroll_y].substr(caretx+(int)scroll_x,lines_p[carety+(int)scroll_y].size()-(caretx+(int)scroll_x));
        tempstring2 = lines_p[carety+(int)scroll_y].substr(0,caretx+(int)scroll_x);
        lines_p[carety+(int)scroll_y] = tempstring2;
        lines_p.insert(itp,tempstring);

        event_key_down(-GLFW_KEY_DOWN,false,false,false);
        event_key_down(-GLFW_KEY_HOME,false,false,false);
        process_line(carety-1+(int)scroll_y);
        process_line(carety+(int)scroll_y);
      }
      if (mirror_keystrokes_object) mirror_keystrokes_object->event_key_down(key, alt, ctrl, shift);
    break;
    // esc
    case -GLFW_KEY_ESC:
    // da rest:
      if (single_row) {
        command_q_b.add_raw("cancel");
        parent->vsx_command_queue_b(this);
      } else
      a_focus = k_focus = parent;
    break;
    default:
      if (key > 0) {
        if (allowed_chars.size()) {
          if (allowed_chars.find(key) == -1) {
            break;
          }
        }
        lines[carety+(int)scroll_y].insert(caretx+(int)scroll_x,(char)key);
        updates++;
        ++caretx;
        if ((size_t)caretx > lines[carety+(int)scroll_y].size()-(int)scroll_x)
        caretx = lines[carety+(int)scroll_y].size()-(int)scroll_x;
        int t_scroll_x = (int)scroll_x;
        if (caretx+(int)scroll_x > characters_width) ++scroll_x;
        //fix_pos();
        //cout << scroll_x - t_scroll_x << endl;
        caretx -= (int)scroll_x - t_scroll_x;
        process_line(carety+(int)scroll_y);
        if (mirror_keystrokes_object) mirror_keystrokes_object->event_key_down(key, alt, ctrl, shift);
      }
    // FROO
  }
  calculate_scroll_size();
  //process_lines();
  if (longest_line-characters_width <= 0) {
    scrollbar_pos_x = 0;
  } else {
    scrollbar_pos_x = (float)scroll_x/(longest_line-characters_width);
  }
  if (longest_y-characters_height <= 0) {
    scrollbar_pos_y = 0;
  } else {
    scrollbar_pos_y = (float)scroll_y/(longest_y-characters_height);
  }
  //printf("scroll_x: %f scroll_y: %f\n caretx: %d  carety: %d\n",scroll_x,scroll_y,caretx,carety);
  return false;
}
Exemple #11
0
  void output(vsx_module_param_abs* param)
  {
    VSX_UNUSED(param);
    if (text_in->updates)
    {
      if (process_lines())
      text_in->updates = 0;
    }
    if (text_alpha->get() <= 0)
      return;

    if (!ftfont)
    {
      user_message = "module||error loading font "+cur_font;
      return;
    }

    if (text_in->get() == "_")
      return;


    float obj_size = size->get();

    gl_state->matrix_mode (VSX_GL_MODELVIEW_MATRIX );
    gl_state->matrix_push();

    gl_state->matrix_rotate_f( (float)angle->get()*360, rotation_axis->get(0), rotation_axis->get(1), rotation_axis->get(2) );

    if (obj_size < 0)
      obj_size = 0;

    gl_state->matrix_scale_f( obj_size*0.8*0.01, obj_size*0.01, obj_size*0.01 );

    int l_align = align->get();
    float l_leading = leading->get();
    float ypos = 0;

    if (cur_render_type == 0)
      glEnable(GL_TEXTURE_2D);

    glColor4f(red->get(),green->get(),blue->get(),text_alpha->get());

    for (unsigned long i = 0; i < lines.size(); ++i)
    {
      float ll = limit_line->get();
      if (ll != -1.0f)
      {
        if (trunc(ll) != i) continue;
      }
      gl_state->matrix_push();
      if (l_align == 0)
      {
        gl_state->matrix_translate_f( 0, ypos, 0 );
      } else
      if (l_align == 1)
      {
        gl_state->matrix_translate_f( -lines[i].size_x*0.5f,ypos,0 );
      }
      if (l_align == 2)
      {
        gl_state->matrix_translate_f( -lines[i].size_x,ypos,0 );
      }

      if (cur_render_type == 1)
      {
        if (outline_alpha->get() > 0.0f && ftfont2) {
          float pre_linew;
          pre_linew = gl_state->line_width_get();
          gl_state->line_width_set( outline_thickness->get() );
          glColor4f(outline_color->get(0),outline_color->get(1),outline_color->get(2),outline_alpha->get()*outline_color->get(3));
          ftfont2->Render(lines[i].string.c_str());
          gl_state->line_width_set( pre_linew );
        }
        glColor4f(red->get(),green->get(),blue->get(),text_alpha->get());
      }

      ftfont->Render(lines[i].string.c_str());
      gl_state->matrix_pop();
      ypos += l_leading;
    }

    if (cur_render_type == 0)
      glDisable(GL_TEXTURE_2D);


    gl_state->matrix_pop();

    render_result->set(1);
    loading_done = true;
  }
Exemple #12
0
/**
 * Hash lines from stdin to files given on command line.
 */
int main(int argc, char * argv[])
{
    int append = 0;
    int first_filename_arg = 1;
    process_lines_context ctx;
    struct fileinfo fileinfo;

    if (argc >= 2 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0))
    {
        printusage();
        exit(0);
    }

    if (argc > 1 && ((strcmp(argv[1], "-a") == 0) || (strcmp(argv[1], "--append") == 0)))
    {
        append = 1;
        first_filename_arg = 2;
    }

    fileinfo.numfiles = argc - first_filename_arg;
    if (fileinfo.numfiles == 0 && append)
    {
        fprintf(stderr, "Can only use --append with files.");
        exit(1);
    }

    fileinfo.files = calloc(fileinfo.numfiles, sizeof (FILE *));
    if (fileinfo.numfiles > 0 && fileinfo.files == NULL)
    {
        perror("hsplit: Error allocating memory");
        exit(1);
    }

    /* Open files. */
    for (unsigned int f = 0 ; f < fileinfo.numfiles ; f++)
    {
        const char * filename = argv[first_filename_arg + f];
        fileinfo.files[f] = fopen(filename, append ? "a" : "w");
        if (fileinfo.files[f] == NULL)
        {
            fprintf(stderr, "hsplit: error opening \"%s\"", filename);
            perror("");
            exit(1);
        }
    }

    if (process_lines_init(&ctx, fileno(stdin), split_lines_to_files, &fileinfo) != 0)
    {
        perror("hsplit");
        exit(1);
    }

    /* Loop: read a line, hash to get file number, write. */
    // TODO: If our hash function had an incremental interface, we could probably do this faster, without buffering.
    int result;
    do {
        result = process_lines(&ctx);
    } while (result == 0);
    if (result > 0)
    {
        perror("hsplit");
        exit(1);
    }

    /* Close files and clean up. */
    process_lines_cleanup(&ctx);
    for (unsigned int f = 0 ; f < fileinfo.numfiles ; f++)
    {
        if (fclose(fileinfo.files[f]) != 0)
        {
            perror("hsplit: Error closing file");
            exit(1);
        }
    }
    free(fileinfo.files);

    return 0;
}