Example #1
0
void
edit_typeset_rep::typeset_sub (SI& x1, SI& y1, SI& x2, SI& y2) {
  //time_t t1= texmacs_time ();
  typeset_prepare ();
  eb= empty_box (reverse (rp));
  // saves memory, also necessary for change_log update
  bench_start ("typeset");
#ifdef USE_EXCEPTIONS
  try {
#endif
    eb= ::typeset (ttt, x1, y1, x2, y2);
#ifdef USE_EXCEPTIONS
  }
  catch (string msg) {
    the_exception= msg;
    std_error << "Typesetting failure, resetting to empty document\n";
    assign (rp, tree (DOCUMENT, ""));
    ::notify_assign (ttt, path(), subtree (et, rp));
    eb= ::typeset (ttt, x1, y1, x2, y2);    
  }
  handle_exceptions ();
#endif
  bench_end ("typeset");
  //time_t t2= texmacs_time ();
  //if (t2 - t1 >= 10) cout << "typeset took " << t2-t1 << "ms\n";
  picture_cache_clean ();
}
Example #2
0
int hfs_read(const char* path, char* buf, size_t bytes, off_t offset, struct fuse_file_info* info)
{
	return handle_exceptions([&]() {

		std::shared_ptr<Reader>& file = *(std::shared_ptr<Reader>*) info->fh;
		return file->read(buf, bytes, offset);
	});
}
Example #3
0
int hfs_getattr(const char* path, struct stat* stat)
{
	std::cerr << "hfs_getattr(" << path << ")\n";

	return handle_exceptions([&]() {
		*stat = g_volume->stat(path);
		return 0;
	});
}
Example #4
0
int hfs_release(const char* path, struct fuse_file_info* info)
{
	// std::cout << "File cache zone: hit rate: " << g_volume->getFileZone()->hitRate() << ", size: " << g_volume->getFileZone()->size() << " blocks\n";

	return handle_exceptions([&]() {

		std::shared_ptr<Reader>* file = (std::shared_ptr<Reader>*) info->fh;
		delete file;
		info->fh = 0;
		
		return 0;
	});
}
Example #5
0
int hfs_getxattr(const char* path, const char* name, char* value, size_t vlen)
{
	std::cerr << "hfs_getxattr(" << path << ", " << name << ")\n";

	return handle_exceptions([&]() -> int {
		std::vector<uint8_t> data;

		data = g_volume->getXattr(path, name);

		if (vlen < data.size())
			return -ERANGE;

		memcpy(value, &data[0], data.size());
		return data.size();
	});
}
Example #6
0
int hfs_open(const char* path, struct fuse_file_info* info)
{
	std::cerr << "hfs_open(" << path << ")\n";

	return handle_exceptions([&]() {

		std::shared_ptr<Reader> file;
		std::shared_ptr<Reader>* fh;

		file = g_volume->openFile(path);
		fh = new std::shared_ptr<Reader>(file);

		info->fh = uint64_t(fh);
		return 0;
	});
}
Example #7
0
int hfs_readlink(const char* path, char* buf, size_t size)
{
	std::cerr << "hfs_readlink(" << path << ")\n";

	return handle_exceptions([&]() {

		std::shared_ptr<Reader> file;
		size_t rd;

		file = g_volume->openFile(path);
		rd = file->read(buf, size-1, 0);
		
		buf[rd] = '\0';
		return 0;
	});
}
Example #8
0
int hfs_listxattr(const char* path, char* buffer, size_t size)
{
	return handle_exceptions([&]() -> int {
		std::vector<std::string> attrs;
		std::vector<char> output;

		attrs = g_volume->listXattr(path);

		for (const std::string& str : attrs)
			output.insert(output.end(), str.c_str(), str.c_str() + str.length() + 1);

		if (size < output.size())
			return -ERANGE;

		memcpy(buffer, &output[0], output.size());
		return output.size();
	});
}
Example #9
0
int hfs_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* info)
{
	std::cerr << "hfs_readdir(" << path << ")\n";

	return handle_exceptions([&]() {
		std::map<std::string, struct stat> contents;

		contents = g_volume->listDirectory(path);

		for (auto it = contents.begin(); it != contents.end(); it++)
		{
			if (filler(buf, it->first.c_str(), &it->second, 0) != 0)
				return -ENOMEM;
		}

		return 0;
	});

}
Example #10
0
void
edit_interface_rep::handle_keypress (string key, time_t t) {
  bool started= false;
#ifdef USE_EXCEPTIONS
  try {
#endif
    if (DEBUG_KEYBOARD) {
      //for (int i=0; i<N(key); i++)
      //  cout << ((int) (unsigned char) key[i]) << " ";
      //cout << "\n";
      debug_keyboard << "Pressed " << key << " at " << t << "\n";
    }
    //time_t t1= texmacs_time ();
    if (is_nil (eb)) apply_changes ();
    start_editing ();
    started= true;
    string zero= "a"; zero[0]= '\0';
    string gkey= replace (key, zero, "<#0>");
    call ("keyboard-press", object (gkey), object ((double) t));
    update_focus_loci ();
    if (!is_nil (focus_ids))
      call ("link-follow-ids", object (focus_ids), object ("focus"));
    notify_change (THE_DECORATIONS);
    end_editing ();
    //time_t t2= texmacs_time ();
    //if (t2 - t1 >= 10) cout << "handle_keypress took " << t2-t1 << "ms\n";
#ifdef USE_EXCEPTIONS
  }
  catch (string msg) {
    if (started) {
      cancel_editing ();
      interrupt_shortcut ();
    }
  }
  handle_exceptions ();
#endif
}