private string GetSelectedText(NLOption opt) { if (_owner == null || _disabledTemporary) { return(null); } StringBuilder bld = new StringBuilder(); TextPoint a = HeadPoint; TextPoint b = TailPoint; GLine l = _owner.Document.FindLineOrEdge(a._line); int pos = a._position; do { bool eol_required = (opt == NLOption.AsLook || l.EOLType != EOLType.Continue); if (l.ID == b._line) //最終行 //末尾にNULL文字が入るケースがあるようだ { AppendTrim(bld, l.Text, pos, b._position - pos); if (_pivotType == RangeType.Line && eol_required) { bld.Append("\r\n"); } break; } else //最終以外の行 { if (l.CharLength - pos > 0) //l.CharLength==posとなるケースがあった。真の理由は納得していないが { AppendTrim(bld, l.Text, pos, l.CharLength - pos); } if (eol_required && bld.Length > 0) //bld.Length>0は行単位選択で余計な改行が入るのを避けるための処置 { bld.Append("\r\n"); //LFのみをクリップボードに持っていっても他のアプリの混乱があるだけなのでやめておく } l = l.NextLine; if (l == null) { break; //!!本来これはないはずだがクラッシュレポートのため回避 } pos = 0; } } while(true); //Debug.WriteLine("Selected Text Len="+bld.Length); return(bld.ToString()); }
private string GetSelectedText(NLOption opt) { if(_owner==null || _disabledTemporary) return null; StringBuilder bld = new StringBuilder(); TextPoint a = HeadPoint; TextPoint b = TailPoint; GLine l = _owner.Document.FindLineOrEdge(a._line); int pos = a._position; do { bool eol_required = (opt==NLOption.AsLook || l.EOLType!=EOLType.Continue); if(l.ID==b._line) { //�ŏI�s //������NULL����������P�[�X������悤�� AppendTrim(bld, l.Text, pos, b._position-pos); if(_pivotType==RangeType.Line && eol_required) bld.Append("\r\n"); break; } else { //�ŏI�ȊO�̍s if(l.CharLength-pos>0) { //l.CharLength==pos�ƂȂ�P�[�X���������B�^�̗��R�͔[�����Ă��Ȃ��� AppendTrim(bld, l.Text, pos, l.CharLength-pos); } if(eol_required && bld.Length>0) //bld.Length>0�͍s�P�ʑI��ŗ]�v�ȉ��s������̂����邽�߂̏��u bld.Append("\r\n"); //LF�݂̂�N���b�v�{�[�h�Ɏ����Ă����Ă���̃A�v���̍��������邾���Ȃ̂ł�߂Ă��� l = l.NextLine; if(l==null) break; //!!�{������͂Ȃ��͂������N���b�V�����|�[�g�̂��߉�� pos = 0; } } while(true); //Debug.WriteLine("Selected Text Len="+bld.Length); return bld.ToString(); }