Ejemplo n.º 1
0
UnicodeString fit_str(const UnicodeString& path, unsigned size) {
  if (path.size() <= size) return path;
  size -= 3; // place for ...
  unsigned ls = size / 2; // left part size
  unsigned rs = size - ls; // right part size
  return path.left(ls) + L"..." + path.right(rs);
}
Ejemplo n.º 2
0
	bool XMLReader::Equals(const UnicodeString & a, const char * b)
	{
		size_t bLen = std::strlen(b);
		if (a.size() != bLen) return false;
		for (size_t i = 0; i < bLen; ++i) {
			if (a[i] != UnicodeChar(b[i])) return false;
		}
		return true;
	}
Ejemplo n.º 3
0
void error_dlg(Error& e, const UnicodeString& message) {
  UnicodeString msg;
  msg.add(far_get_msg(MSG_PLUGIN_NAME)).add('\n');
  if (message.size() != 0) msg.add(word_wrap(message, get_msg_width())).add('\n');
  UnicodeString err_msg = word_wrap(e.message(), get_msg_width());
  if (err_msg.size() != 0) msg.add(err_msg).add('\n');
  msg.add_fmt(L"%S:%u v.%u.%u.%u.%u"PLUGIN_TYPE, &extract_file_name(oem_to_unicode(e.file)), e.line, g_version.major, g_version.minor, g_version.patch, g_version.revision);
  far_message(c_error_dialog_guid, msg, 0, FMSG_WARNING | FMSG_MB_OK);
}
Ejemplo n.º 4
0
	bool XMLReader::IsNameToken(const UnicodeString & token)
	{
		// Nmtoken ::= (NameChar)+
		size_t n = token.size();
		if (n == 0) return false;
		for (size_t i = 0; i < n; ++i) {
			if (! IsNameChar(token[i])) return false;
		}
		return true;
	}
Ejemplo n.º 5
0
	bool XMLReader::IsName(const UnicodeString & name)
	{
		// Name ::= (Letter | '_' | ':') (NameChar)*
		size_t n = name.size();
		if (n == 0) return false;
		UnicodeChar c = name[0];
		if ((c == UnicodeChar('_')) || (c == UnicodeChar(':')) || IsLetter(c)) {
			for (size_t i = 1; i < n; ++i) {
				if (! IsNameChar(name[i])) return false;
			}
		}
		return true;
	}
Ejemplo n.º 6
0
UnicodeString word_wrap(const UnicodeString& message, unsigned wrap_bound) {
  UnicodeString msg = message;
  unsigned limit = wrap_bound;
  unsigned idx = -1;
  for (unsigned i = 0; i < msg.size(); i++) {
    if (i >= limit) {
      if (idx != -1) {
        msg.insert(idx, '\n');
        i = idx + 1;
        limit = idx + 2 + wrap_bound;
        idx = -1;
        continue;
      }
    }
    if (msg[i] == ' ') idx = i;
  }
  return msg;
}
Ejemplo n.º 7
0
void AppGuiBase::Render( Gwen::Skin::Base* skin )
{
	m_iFrames++;
    
	if ( m_fLastSecond < Gwen::Platform::GetTimeInSeconds() )
	{
        Controls::Layout::Table* logTable = logWindow->m_TextOutput->GetTable();
        
        UnicodeString lastStatus;
        
        if( logTable->RowCount(0) ) {
            lastStatus = logTable->GetRow( logTable->RowCount(0)-1 )->GetText(0).GetUnicode();
            lastStatus.erase(lastStatus.size()-1);
        }
		m_StatusBar->SetText( lastStatus + Gwen::Utility::Format( L" - %i fps", /*m_iFrames * 2 */ (int)ofGetFrameRate() ) );
		m_fLastSecond = Gwen::Platform::GetTimeInSeconds() + 0.5f;
		m_iFrames = 0;
	}
    
	BaseClass::Render( skin );
}
Ejemplo n.º 8
0
// unicode <-> oem codepage conversions
void unicode_to_oem(AnsiString& oem_str, const UnicodeString& u_str) {
  unsigned size = u_str.size() + 1;
  int res = WideCharToMultiByte(CP_OEMCP, 0, u_str.data(), size, oem_str.buf(u_str.size()), size, NULL, NULL);
  if (res == 0) FAIL(SystemError());
  oem_str.set_size(res - 1);
}
Ejemplo n.º 9
0
UnicodeString del_trailing_slash(const UnicodeString& file_path) {
  if ((file_path.size() < 2) || (file_path.last() != L'\\')) return file_path;
  else return file_path.left(file_path.size() - 1);
}
Ejemplo n.º 10
0
UnicodeString add_trailing_slash(const UnicodeString& file_path) {
  if ((file_path.size() == 0) || (file_path.last() == L'\\')) return file_path;
  else return file_path + L'\\';
}
Ejemplo n.º 11
0
void unquote(UnicodeString& str) {
  if ((str.size() >= 2) && (str[0] == '"') && (str.last() == '"')) {
    str.remove(0);
    str.remove(str.size() - 1);
  }
}
Ejemplo n.º 12
0
const UnicodeString extract_file_name(const UnicodeString& file_path) {
  unsigned pos = file_path.rsearch('\\');
  if (pos == -1) pos = 0;
  else pos++;
  return file_path.slice(pos, file_path.size() - pos);
}
Ejemplo n.º 13
0
UnicodeString center(const UnicodeString& str, unsigned width) {
  if (str.size() >= width) return str;
  unsigned lpad = (width - str.size()) / 2;
  unsigned rpad = width - str.size() - lpad;
  return UnicodeString::format(L"%.*c%S%.*c", lpad, ' ', &str, rpad, ' ');
}
Ejemplo n.º 14
0
const UnicodeString & __fastcall UnicodeString::operator +=(const UnicodeString & rhs)
{
  Data.append(rhs.Data.c_str(), rhs.size());
  return *this;
}
Ejemplo n.º 15
0
void msg_dlg(const UnicodeString& message) {
  UnicodeString msg;
  msg.add(far_get_msg(MSG_PLUGIN_NAME)).add('\n');
  if (message.size() != 0) msg.add(word_wrap(message, get_msg_width())).add('\n');
  far_message(c_error_dialog_guid, msg, 0, FMSG_MB_OK);
}