/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// Handle deletion of text in a preedit_draw_callback // from and howmuch are guaranteed to be nonnegative
staticvoid
Preedit_DeleteText(preedit_text_t *ptext, int from, int howmuch)
{ // If we've been asked to delete no text then just set // nLength correctly and return if (ptext->nLength == 0)
{
ptext->nLength = from; return;
}
int to = from + howmuch;
if (to == static_cast<int>(ptext->nLength))
{ // delete from the end of the text
ptext->nLength = from;
} elseif (to < static_cast<int>(ptext->nLength))
{ // cut out of the middle of the text
memmove( static_cast<void*>(ptext->pUnicodeBuffer + from), static_cast<void*>(ptext->pUnicodeBuffer + to),
(ptext->nLength - to) * sizeof(sal_Unicode));
memmove( static_cast<void*>(ptext->pCharStyle + from), static_cast<void*>(ptext->pCharStyle + to),
(ptext->nLength - to) * sizeof(XIMFeedback));
ptext->nLength -= howmuch;
} else
{ // XXX this indicates an error, are we out of sync ?
SAL_INFO("vcl.app", "Preedit_DeleteText( from=" << from
<< " to=" << to
<< " length=" << ptext->nLength
<< " ).");
fprintf (stderr, "\t XXX internal error, out of sync XXX\n");
ptext->nLength = from;
}
// NULL-terminate the string
ptext->pUnicodeBuffer[ptext->nLength] = u'\0';
}
// reallocate the textbuffer with sufficiently large size 2^x // nnewlimit is presupposed to be larger than ptext->size staticvoid
enlarge_buffer ( preedit_text_t *ptext, int nnewlimit )
{
size_t nnewsize = ptext->nSize;
while ( nnewsize <= o3tl::make_unsigned(nnewlimit) )
nnewsize *= 2;
// Convert the XIM feedback values into appropriate VCL // EXTTEXTINPUT_ATTR values // returns an allocate list of attributes, which must be freed by caller static ExtTextInputAttr*
Preedit_FeedbackToSAL ( const XIMFeedback* pfeedback, int nlength, std::vector<ExtTextInputAttr>& rSalAttr )
{
ExtTextInputAttr *psalattr;
ExtTextInputAttr nval;
ExtTextInputAttr noldval = ExtTextInputAttr::NONE;
XIMFeedback nfeedback;
// only work with reasonable length if (nlength > 0 && nlength > sal::static_int_cast<int>(rSalAttr.size()) )
{
rSalAttr.reserve( nlength );
psalattr = rSalAttr.data();
} else return nullptr;
// means to use the feedback of the previous char if (nfeedback == 0)
{
nval = noldval;
} // convert feedback to attributes else
{ if (nfeedback & XIMReverse)
nval |= ExtTextInputAttr::Highlight; if (nfeedback & XIMUnderline)
nval |= ExtTextInputAttr::Underline; if (nfeedback & XIMHighlight)
nval |= ExtTextInputAttr::Highlight; if (nfeedback & XIMPrimary)
nval |= ExtTextInputAttr::DottedUnderline; if (nfeedback & XIMSecondary)
nval |= ExtTextInputAttr::DashDotUnderline; if (nfeedback & XIMTertiary) // same as 2ery
nval |= ExtTextInputAttr::DashDotUnderline;
} // copy in list
psalattr[npos] = nval;
noldval = nval;
} // return list of sal attributes return psalattr;
}
// if there's nothing to change then change nothing if ( ( (call_data->text == nullptr) && (call_data->chg_length == 0) )
|| pPreeditData->pFrame == nullptr ) return;
// Solaris 7 deletes the preedit buffer after commit // since the next call to preeditstart will have the same effect just skip this. // if (pPreeditData->eState == ePreeditStatusStartPending && call_data->text == NULL) // return;
#if OSL_DEBUG_LEVEL > 1 void
PreeditCaretCallback ( XIC ic, XPointer client_data,
XIMPreeditCaretCallbackStruct *call_data )
{ // XXX PreeditCaretCallback is pure debug code for now constchar *direction = "?"; constchar *style = "?";
switch ( call_data->style )
{ case XIMIsInvisible: style = "Invisible"; break; case XIMIsPrimary: style = "Primary"; break; case XIMIsSecondary: style = "Secondary"; break;
} switch ( call_data->direction )
{ case XIMForwardChar: direction = "Forward char"; break; case XIMBackwardChar: direction = "Backward char"; break; case XIMForwardWord: direction = "Forward word"; break; case XIMBackwardWord: direction = "Backward word"; break; case XIMCaretUp: direction = "Caret up"; break; case XIMCaretDown: direction = "Caret down"; break; case XIMNextLine: direction = "Next line"; break; case XIMPreviousLine: direction = "Previous line"; break; case XIMLineStart: direction = "Line start"; break; case XIMLineEnd: direction = "Line end"; break; case XIMAbsolutePosition: direction = "Absolute"; break; case XIMDontChange: direction = "Don't change"; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.