本文整理汇总了C++中GetCurrentPos函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCurrentPos函数的具体用法?C++ GetCurrentPos怎么用?C++ GetCurrentPos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetCurrentPos函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: BraceMatch
/* TextEditor::checkBraceMatch
* Checks for a brace match at the current cursor position
*******************************************************************/
void TextEditor::checkBraceMatch()
{
#ifdef __WXMAC__
bool refresh = false;
#else
bool refresh = true;
#endif
// Check for brace match at current position
int bracematch = BraceMatch(GetCurrentPos());
if (bracematch != wxSTC_INVALID_POSITION)
{
BraceHighlight(GetCurrentPos(), bracematch);
if (refresh) Refresh();
return;
}
// No match, check for match at previous position
bracematch = BraceMatch(GetCurrentPos() - 1);
if (bracematch != wxSTC_INVALID_POSITION)
{
BraceHighlight(GetCurrentPos() - 1, bracematch);
if (refresh) Refresh();
return;
}
// No match at all, clear any previous brace match
BraceHighlight(-1, -1);
if (refresh) Refresh();
}
开发者ID:macressler,项目名称:SLADE,代码行数:33,代码来源:TextEditor.cpp
示例2: SetFocus
/* TextEditor::showFindReplacePanel
* Shows or hides the Find+Replace panel, depending on [show]. If
* shown, fills the find text box with the current selection or the
* current word at the caret
*******************************************************************/
void TextEditor::showFindReplacePanel(bool show)
{
// Do nothing if no F+R panel has been set
if (!panel_fr)
return;
// Hide if needed
if (!show)
{
panel_fr->Hide();
panel_fr->GetParent()->Layout();
SetFocus();
return;
}
// Get currently selected text
string find = GetSelectedText();
// Get the word at the current cursor position if there is no current selection
if (find.IsEmpty())
{
int ws = WordStartPosition(GetCurrentPos(), true);
int we = WordEndPosition(GetCurrentPos(), true);
find = GetTextRange(ws, we);
}
// Show the F+R panel
panel_fr->Show();
panel_fr->GetParent()->Layout();
panel_fr->setFindText(find);
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:36,代码来源:TextEditor.cpp
示例3: CalculatePos
void ContainerStacker::DriveToPoint() {
SmartDashboard::PutNumber("TargetPosition", m_targetHeight);
int position = CalculatePos();
double error = position - GetCurrentPos();
SmartDashboard::PutNumber("error, can", error);
SmartDashboard::PutNumber("current, can", GetCurrentPos());
SmartDashboard::PutNumber("point, can", position);
CheckSensors();
if(error > 50){
if(error > 1000) {
containerLift->Set(-1);
}
else {
containerLift->Set(-error/1000);
}
}
else if(error < -50) {
if(error < -1000) {
containerLift->Set(1);
}
else {
containerLift->Set(-error/1000);
}
}
else {
containerLift->Set(0);
}
}
开发者ID:CRRobotics,项目名称:Robots,代码行数:32,代码来源:ContainerStacker.cpp
示例4: GetCurrentPos
void ContainerStacker::DriveToPoint(int point) {
double error = point - GetCurrentPos();
SmartDashboard::PutNumber("error1, can", error);
SmartDashboard::PutNumber("current1, can", GetCurrentPos());
SmartDashboard::PutNumber("point1, can", point);
CheckSensors();
if(error > 50){
if(error > 1000) {
containerLift->Set(-1);
}
else {
containerLift->Set(-error/1000);
}
}
else if(error < -50) {
if(error < -1000) {
containerLift->Set(1);
}
else {
containerLift->Set(-error/1000);
}
}
else {
containerLift->Set(0);
}
}
开发者ID:CRRobotics,项目名称:Robots,代码行数:26,代码来源:ContainerStacker.cpp
示例5: S_FMT
/* TextEditor::onCharAdded
* Called when a character is added to the text
*******************************************************************/
void TextEditor::onCharAdded(wxStyledTextEvent& e)
{
// Update line numbers margin width
string numlines = S_FMT("0%d", GetNumberOfLines());
SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));
// Auto indent
int currentLine = GetCurrentLine();
if (txed_auto_indent && e.GetKey() == '\n')
{
// Get indentation amount
int lineInd = 0;
if (currentLine > 0)
lineInd = GetLineIndentation(currentLine - 1);
// Do auto-indent if needed
if (lineInd != 0)
{
SetLineIndentation(currentLine, lineInd);
// Skip to end of tabs
while (1)
{
int chr = GetCharAt(GetCurrentPos());
if (chr == '\t' || chr == ' ')
GotoPos(GetCurrentPos()+1);
else
break;
}
}
}
// The following require a language to work
if (language)
{
// Call tip
if (e.GetKey() == '(' && txed_calltips_parenthesis)
{
openCalltip(GetCurrentPos());
}
// End call tip
if (e.GetKey() == ')')
{
CallTipCancel();
}
// Comma, possibly update calltip
if (e.GetKey() == ',' && txed_calltips_parenthesis)
{
//openCalltip(GetCurrentPos());
//if (CallTipActive())
updateCalltip();
}
}
// Continue
e.Skip();
}
开发者ID:macressler,项目名称:SLADE,代码行数:62,代码来源:TextEditor.cpp
示例6: switch
void cbStyledTextCtrl::OnKeyDown(wxKeyEvent& event)
{
switch (event.GetKeyCode())
{
case WXK_TAB:
{
if (m_tabSmartJump && !(event.ControlDown() || event.ShiftDown() || event.AltDown()))
{
if (!AutoCompActive() && m_bracePosition != wxSCI_INVALID_POSITION)
{
m_lastPosition = GetCurrentPos();
GotoPos(m_bracePosition);
// Need judge if it's the final brace
HighlightRightBrace();
if (!m_tabSmartJump && CallTipActive())
CallTipCancel();
return;
}
}
}
break;
case WXK_BACK:
{
if (m_tabSmartJump)
{
if (!(event.ControlDown() || event.ShiftDown() || event.AltDown()))
{
const int pos = GetCurrentPos();
const int index = s_leftBrace.Find((wxChar)GetCharAt(pos - 1));
if (index != wxNOT_FOUND && (wxChar)GetCharAt(pos) == s_rightBrace.GetChar(index))
{
CharRight();
DeleteBack();
}
}
else if (m_lastPosition != wxSCI_INVALID_POSITION && event.ControlDown())
{
GotoPos(m_lastPosition);
m_lastPosition = wxSCI_INVALID_POSITION;
return;
}
}
}
break;
case WXK_RETURN:
case WXK_ESCAPE:
{
if (m_tabSmartJump)
m_tabSmartJump = false;
}
break;
}
event.Skip();
}
开发者ID:stahta01,项目名称:EmBlocks_old,代码行数:58,代码来源:cbstyledtextctrl.cpp
示例7: checkBraceMatch
/* TextEditor::onUpdateUI
* Called when anything is modified in the text editor (cursor
* position, styling, text, etc)
*******************************************************************/
void TextEditor::onUpdateUI(wxStyledTextEvent& e)
{
// Check for brace match
if (txed_brace_match)
checkBraceMatch();
// If a calltip is open, update it
if (call_tip->IsShown())
updateCalltip();
// Do word matching if appropriate
if (txed_match_cursor_word && language)
{
int word_start = WordStartPosition(GetCurrentPos(), true);
int word_end = WordEndPosition(GetCurrentPos(), true);
string current_word = GetTextRange(word_start, word_end);
if (!current_word.IsEmpty() && HasFocus())
{
if (current_word != prev_word_match)
{
prev_word_match = current_word;
SetIndicatorCurrent(8);
IndicatorClearRange(0, GetTextLength());
SetTargetStart(0);
SetTargetEnd(GetTextLength());
SetSearchFlags(0);
while (SearchInTarget(current_word) != -1)
{
IndicatorFillRange(GetTargetStart(), GetTargetEnd() - GetTargetStart());
SetTargetStart(GetTargetEnd());
SetTargetEnd(GetTextLength());
}
}
}
else
{
SetIndicatorCurrent(8);
IndicatorClearRange(0, GetTextLength());
prev_word_match = "";
}
}
// Hilight current line
MarkerDeleteAll(1);
MarkerDeleteAll(2);
if (txed_hilight_current_line > 0 && HasFocus())
{
int line = LineFromPosition(GetCurrentPos());
MarkerAdd(line, 1);
if (txed_hilight_current_line > 1)
MarkerAdd(line, 2);
}
e.Skip();
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:60,代码来源:TextEditor.cpp
示例8: GetCurrentLine
void CodeEditor::OnCharAdded(wxScintillaEvent &event)
{
char ch = event.GetKey();
int currentLine = GetCurrentLine();
int pos = GetCurrentPos();
if (ch == wxT('\n') && currentLine > 0)
{
BeginUndoAction();
wxString indent = GetLineIndentString(currentLine - 1);
wxChar b = GetLastNonWhitespaceChar();
if(b == wxT('{'))
{
if(GetUseTabs())
indent << wxT("\t");
else
indent << wxT(" ");
}
InsertText(pos, indent);
GotoPos((int)(pos + indent.Length()));
ChooseCaretX();
EndUndoAction();
}
else if(ch == wxT('}'))
{
BeginUndoAction();
wxString line = GetLine(currentLine);
line.Trim(false);
line.Trim(true);
if(line.Matches(wxT("}")))
{
pos = GetCurrentPos() - 2;
pos = FindBlockStart(pos, wxT('{'), wxT('}'));
if(pos != -1)
{
wxString indent = GetLineIndentString(LineFromPosition(pos));
indent << wxT('}');
DelLineLeft();
DelLineRight();
pos = GetCurrentPos();
InsertText(pos, indent);
GotoPos((int)(pos + indent.Length()));
ChooseCaretX();
}
}
EndUndoAction();
}
}
开发者ID:bill9889,项目名称:OGRE,代码行数:55,代码来源:CodeEditor.cpp
示例9: GetCurrentPos
CString ScintillaEditor::GetWord()
{
int savePos = GetCurrentPos();
SendEditor(SCI_WORDLEFT);
DWORD startPos = GetCurrentPos();
SendEditor(SCI_WORDRIGHTEXTEND);
DWORD endPos = GetCurrentPos();
CStringA str;
LPSTR buf = str.GetBufferSetLength(endPos - startPos);
GetSelText(buf);
str.ReleaseBuffer(endPos - startPos);
SendEditor(SCI_SETCURRENTPOS, savePos);
return CString(str);
}
开发者ID:WeyrSDev,项目名称:gamecode3,代码行数:15,代码来源:ScintillaEditor.cpp
示例10: GetCurrentLine
void MaterialScriptEditor::OnCharAdded(wxScintillaEvent &event)
{
ScintillaEditor::OnCharAdded(event);
char ch = event.GetKey();
if(getCallTipManager().isTrigger(ch))
{
int lineNum = GetCurrentLine();
if(lineNum != -1)
{
wxString line = GetLine(lineNum);
int pos = GetCurrentPos() - 1;
wxString word("");
wxChar ch;
while(pos)
{
ch = GetCharAt(--pos);
if(ch != ' ' && ch != '\n' && ch != '\r' && ch != '\t' && ch != '{' && ch != '}') word.Prepend(ch);
else break;
}
wxString* tips = getCallTipManager().find(word);
if(tips != NULL)
{
CallTipShow(pos, *tips);
}
}
}
}
开发者ID:gorkinovich,项目名称:DefendersOfMankind,代码行数:30,代码来源:MaterialScriptEditor.cpp
示例11: GetCurrentPos
wxChar CodeEditor::GetLastNonWhitespaceChar(int position /* = -1 */)
{
if (position == -1)
position = GetCurrentPos();
int count = 0; // Used to count the number of blank lines
bool foundlf = false; // For the rare case of CR's without LF's
while (position)
{
wxChar c = GetCharAt(--position);
int style = GetStyleAt(position);
bool inComment = style == wxSCI_C_COMMENT ||
style == wxSCI_C_COMMENTDOC ||
style == wxSCI_C_COMMENTDOCKEYWORD ||
style == wxSCI_C_COMMENTDOCKEYWORDERROR ||
style == wxSCI_C_COMMENTLINE ||
style == wxSCI_C_COMMENTLINEDOC;
if (c == wxT('\n'))
{
count++;
foundlf = true;
}
else if (c == wxT('\r') && !foundlf)
count++;
else
foundlf = false;
if (count > 1) return 0; // Don't over-indent
if (!inComment && c != wxT(' ') && c != wxT('\t') && c != wxT('\n') && c != wxT('\r'))
return c;
}
return 0;
}
开发者ID:bill9889,项目名称:OGRE,代码行数:33,代码来源:CodeEditor.cpp
示例12: s_DefEndPos
void DlgEditMusic::s_DefEndPos() {
if (StopMaj) return;
MusicObject->EndPos=GetCurrentPos();
if (MusicObject->EndPos>=MusicObject->GetRealDuration()) MusicObject->EndPos=MusicObject->GetRealDuration().addMSecs(-1);
ui->CustomRuler->EndPos=QTime(0,0,0,0).msecsTo(MusicObject->EndPos);
RefreshControls();
}
开发者ID:JonasCz,项目名称:ffdiaporama-1604-builds,代码行数:7,代码来源:DlgEditMusic.cpp
示例13: FindDialog
bool SearchableEditor::find(bool newSearch)
{
if (!fd)
fd = new FindDialog(this, ::wxGetTopLevelParent(this));
if (newSearch || findTextM.empty())
{
if (newSearch)
{
// find selected text
wxString findText(GetSelectedText());
// failing that initialize with the word at the caret
if (findText.empty())
{
int pos = GetCurrentPos();
int start = WordStartPosition(pos, true);
int end = WordEndPosition(pos, true);
if (end > start)
findText = GetTextRange(start, end);
}
fd->SetFindText(findText);
}
// do not re-center dialog if it is already visible
if (!fd->IsShown())
fd->Show();
fd->SetFocus();
return false; // <- caller shouldn't care about this
}
int start = GetSelectionEnd();
if (findFlagsM.has(se::FROM_TOP))
{
start = 0;
findFlagsM.remove(se::ALERT); // remove flag after first find
}
int end = GetTextLength();
int p = FindText(start, end, findTextM, findFlagsM.asStc());
if (p == -1)
{
if (findFlagsM.has(se::WRAP))
p = FindText(0, end, findTextM, findFlagsM.asStc());
if (p == -1)
{
if (findFlagsM.has(se::ALERT))
wxMessageBox(_("No more matches"), _("Search complete"), wxICON_INFORMATION|wxOK);
return false;
}
}
centerCaret(true);
GotoPos(p);
GotoPos(p + findTextM.Length());
SetSelectionStart(p);
SetSelectionEnd(p + findTextM.Length());
centerCaret(false);
return true;
}
开发者ID:DragonZX,项目名称:flamerobin,代码行数:57,代码来源:FindDialog.cpp
示例14: AssignMolType
/// Override logic for assigning the molecule type
/// @note fForceType is ignored if the sequence length is less than the
/// value configured in the constructor
virtual void AssignMolType(ILineErrorListener * pMessageListener) {
if (GetCurrentPos(eRawPos) < m_SeqLenThreshold) {
_ASSERT( (TestFlag(fAssumeNuc) ^ TestFlag(fAssumeProt) ) );
SetCurrentSeq().SetInst().SetMol(TestFlag(fAssumeNuc)
? CSeq_inst::eMol_na
: CSeq_inst::eMol_aa);
} else {
CFastaReader::AssignMolType(pMessageListener);
}
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:13,代码来源:blast_fasta_input.cpp
示例15: GetCurrentPos
void Edit::OnBraceMatch (wxCommandEvent &WXUNUSED(event)) {
int min = GetCurrentPos ();
int max = BraceMatch (min);
if (max > (min+1)) {
BraceHighlight (min+1, max);
SetSelection (min+1, max);
}else{
BraceBadLight (min);
}
}
开发者ID:jfiguinha,项目名称:Regards,代码行数:10,代码来源:edit.cpp
示例16: AddLineInfos
void SQFuncState::AddLineInfos(SQInteger line,bool lineop,bool force)
{
if(_lastline!=line || force){
SQLineInfo li;
li._line=line;li._op=(GetCurrentPos()+1);
if(lineop)AddInstruction(_OP_LINE,0,line);
_lineinfos.push_back(li);
_lastline=line;
}
}
开发者ID:IchiroWang,项目名称:OpenTTD,代码行数:10,代码来源:sqfuncstate.cpp
示例17: GetCurrentPos
void ctlSQLBox::OnPositionStc(wxStyledTextEvent &event)
{
int pos = GetCurrentPos();
wxChar ch = GetCharAt(pos - 1);
int st = GetStyleAt(pos - 1);
int match;
// Line numbers
// Ensure we don't recurse through any paint handlers on Mac
#ifdef __WXMAC__
Freeze();
#endif
UpdateLineNumber();
#ifdef __WXMAC__
Thaw();
#endif
// Clear all highlighting
BraceBadLight(wxSTC_INVALID_POSITION);
// Check for braces that aren't in comment styles,
// double quoted styles or single quoted styles
if ((ch == '{' || ch == '}' ||
ch == '[' || ch == ']' ||
ch == '(' || ch == ')') &&
st != 2 && st != 6 && st != 7)
{
match = BraceMatch(pos - 1);
if (match != wxSTC_INVALID_POSITION)
BraceHighlight(pos - 1, match);
}
// Roll back through the doc and highlight any unmatched braces
while ((pos--) >= 0)
{
ch = GetCharAt(pos);
st = GetStyleAt(pos);
if ((ch == '{' || ch == '}' ||
ch == '[' || ch == ']' ||
ch == '(' || ch == ')') &&
st != 2 && st != 6 && st != 7)
{
match = BraceMatch(pos);
if (match == wxSTC_INVALID_POSITION)
{
BraceBadLight(pos);
break;
}
}
}
event.Skip();
}
开发者ID:Timosha,项目名称:pgadmin3,代码行数:55,代码来源:ctlSQLBox.cpp
示例18: GetCurrentPos
bool cbStyledTextCtrl::AllowTabSmartJump()
{
const int pos = GetCurrentPos();
if (pos == wxSCI_INVALID_POSITION)
return false;
const int style = GetStyleAt(pos);
if (IsString(style) || IsCharacter(style) || IsComment(style) || IsPreprocessor(style))
return !m_tabSmartJump;
return true;
}
开发者ID:simple-codeblocks,项目名称:Codeblocks,代码行数:11,代码来源:cbstyledtextctrl.cpp
示例19: if
void CodeEdit::OnCharAdded(wxStyledTextEvent& event)
{
// Indent the line to the same indentation as the previous line.
// Adapted from http://STCntilla.sourceforge.net/STCntillaUsage.html
char ch = event.GetKey();
if (ch == '\r' || ch == '\n')
{
int line = GetCurrentLine();
int lineLength = LineLength(line);
if (line > 0 && lineLength <= 2)
{
wxString buffer = GetLine(line - 1);
for (unsigned int i = 0; i < buffer.Length(); ++i)
{
if (buffer[i] != ' ' && buffer[i] != '\t')
{
buffer.Truncate(i);
break;
}
}
ReplaceSelection(buffer);
// Remember that we just auto-indented so that the backspace
// key will un-autoindent us.
m_autoIndented = true;
}
}
else if (m_enableAutoComplete && m_autoCompleteManager != NULL)
{
// Handle auto completion.
wxString token;
if (GetTokenFromPosition(GetCurrentPos() - 1, ".:", token))
{
StartAutoCompletion(token);
}
}
event.Skip();
}
开发者ID:Halfbrick,项目名称:decoda,代码行数:54,代码来源:CodeEdit.cpp
示例20: PushLocalVariable
SQInteger SQFuncState::PushLocalVariable(const SQObject &name)
{
SQInteger pos=_vlocals.size();
SQLocalVarInfo lvi;
lvi._name=name;
lvi._start_op=GetCurrentPos()+1;
lvi._pos=_vlocals.size();
_vlocals.push_back(lvi);
if(_vlocals.size()>((SQUnsignedInteger)_stacksize))_stacksize=_vlocals.size();
return pos;
}
开发者ID:henryrao,项目名称:kdguigl,代码行数:11,代码来源:sqfuncstate.cpp
注:本文中的GetCurrentPos函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论