예제 #1
0
bool TextInputMenu::IsCurrentLineEmpty(UInt32 fromPos) const
{
	if (FindLineEnd(fromPos) - FindLineStart(fromPos) == 1)
		return true;
	else
		return false;
}
예제 #2
0
파일: POUtils.cpp 프로젝트: FLyrfors/xbmc
bool CPODocument::GetNextEntry()
{
  do
  {
    // if we don't find LFLF, we reached the end of the buffer and the last entry to check
    // we indicate this with setting m_nextEntryPos to the end of the buffer
    if ((m_nextEntryPos = m_strBuffer.find("\n\n", m_CursorPos)) == std::string::npos)
      m_nextEntryPos = m_POfilelength-1;

    // now we read the actual entry into a temp string for further processing
    m_Entry.Content.assign(m_strBuffer, m_CursorPos, m_nextEntryPos - m_CursorPos +1);
    m_CursorPos = m_nextEntryPos+1; // jump cursor to the second LF character

    if (FindLineStart ("\nmsgid ", m_Entry.msgID.Pos))
    {
      if (FindLineStart ("\nmsgctxt \"#", m_Entry.xIDPos) && ParseNumID())
      {
        m_Entry.Type = ID_FOUND; // we found an entry with a valid numeric id
        return true;
      }

      size_t plurPos;
      if (FindLineStart ("\nmsgid_plural ", plurPos))
      {
        m_Entry.Type = MSGID_PLURAL_FOUND; // we found a pluralized entry
        return true;
      }

      m_Entry.Type = MSGID_FOUND; // we found a normal entry, with no numeric id
      return true;
    }
  }
  while (m_nextEntryPos != m_POfilelength-1);
  // we reached the end of buffer AND we have not found a valid entry

  return false;
}
예제 #3
0
//returns -1 if code not handled, otherwise returns new insertion pos
UInt32 TextInputJournal::ResolveControlCode(UInt8 controlCode, UInt32 insertPos)
{
	if (IsFull())
		return -1;

	UInt32 newPos = insertPos;

	switch (controlCode)
	{
	case DIK_RETURN: //line break
		newPos = InsertText(insertPos, kTagStrings[kHTMLTag_BR].c_str());
		break;
	case DIK_UP:	//move to end of previous line
		newPos = FindLineStart(insertPos);
		if (newPos > GetMinPos())
			newPos = SeekPosition(newPos, true, true);

		break;
	case DIK_DOWN:	//move to start of next line
		newPos = FindLineEnd(insertPos);
		if (newPos <= GetMaxPos())
			newPos = SeekPosition(newPos, false, true);

		break;
	case DIK_C:		//align center
		newPos = SetLineStartingTag(insertPos, kHTMLTag_DIV_Center);
		break;
	case DIK_L:		//align left
		newPos = SetLineStartingTag(insertPos, kHTMLTag_DIV_Left);
		break;
	case DIK_R:		//align right
		newPos = SetLineStartingTag(insertPos, kHTMLTag_DIV_Right);
		break;
	case DIK_1:
	case DIK_2:
	case DIK_3:
	case DIK_4:
	case DIK_5:		//Change font
		{
			char fontNum = controlCode - DIK_1 + '1';
			m_inputText[12] = fontNum;
			break;
		}
	default:
		newPos = -1;
	}

	return newPos;
}
예제 #4
0
//returns new insertion point on current line
UInt32 TextInputJournal::SetLineStartingTag(UInt32 fromPos, UInt32 tagType)
{
	UInt32 newPos = fromPos;

	UInt32 startPos = FindLineStart(fromPos);
	bool bUpdateMinPos = (startPos == m_minPos);		//changing first tag in text requires updating min pos too

	UInt32 lBracPos = FindHTMLMatchedBracket(startPos - 1, true);

	//replace previous tag with new one
	m_inputText.erase(lBracPos, startPos - lBracPos);
	newPos -= startPos - lBracPos;
	if (bUpdateMinPos)
		m_minPos -= startPos - lBracPos;

	m_inputText.insert(lBracPos, kTagStrings[tagType]);
	newPos += kTagStrings[tagType].length();
	if (bUpdateMinPos)
		m_minPos += kTagStrings[tagType].length();

	return newPos;
}
예제 #5
0
파일: POUtils.cpp 프로젝트: FLyrfors/xbmc
void CPODocument::ParseEntry(bool bisSourceLang)
{
  if (bisSourceLang)
  {
    if (m_Entry.Type == ID_FOUND)
      GetString(m_Entry.msgID);
    else
      m_Entry.msgID.Str.clear();
    return;
  }

  if (m_Entry.Type != ID_FOUND)
  {
    GetString(m_Entry.msgID);
    if (FindLineStart ("\nmsgctxt ", m_Entry.msgCtxt.Pos))
      GetString(m_Entry.msgCtxt);
    else
      m_Entry.msgCtxt.Str.clear();
  }

  if (m_Entry.Type != MSGID_PLURAL_FOUND)
  {
    if (FindLineStart ("\nmsgstr ", m_Entry.msgStr.Pos))
    {
      GetString(m_Entry.msgStr);
      GetString(m_Entry.msgID);
    }
    else
    {
      CLog::Log(LOGERROR, "POParser: missing msgstr line in entry. Failed entry: %s",
                m_Entry.Content.c_str());
      m_Entry.msgStr.Str.clear();
    }
    return;
  }

  // We found a plural form entry. We read it into a vector of CStrEntry types
  m_Entry.msgStrPlural.clear();
  std::string strPattern = "\nmsgstr[0] ";
  CStrEntry strEntry;

  for (int n=0; n<7 ; n++)
  {
    strPattern[8] = static_cast<char>(n+'0');
    if (FindLineStart (strPattern, strEntry.Pos))
    {
      GetString(strEntry);
      if (strEntry.Str.empty())
        break;
      m_Entry.msgStrPlural.push_back(strEntry);
    }
    else
      break;
  }

  if (m_Entry.msgStrPlural.empty())
  {
    CLog::Log(LOGERROR, "POParser: msgstr[] plural lines have zero valid strings. "
                        "Failed entry: %s", m_Entry.Content.c_str());
    m_Entry.msgStrPlural.resize(1); // Put 1 element with an empty string into the vector
  }

  return;
}