• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會(huì)很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::

                /**

                 * Delete the line where the cursor is positioned.

                 */

                public void deleteCurrentLine() {

                    // ab^EndPos: so EndPos is 3, there are 2 characters a, b, ^ is the flag

                    // of end of the document.

                    int length = getDocument().getLength();

                    if (length <= 0) { return; }


                    Element root = getDocument().getDefaultRootElement();

                    int pos = getCaretPosition();

                    int lineNumber = root.getElementIndex(pos); // 取得光標(biāo)所在行的行號(hào)

                    Element e = root.getElement(lineNumber);


                    int start = e.getStartOffset();

                    int end = e.getEndOffset(); // 取得所在行最后回車的下一個(gè)位置, 有可能是文檔結(jié)束位置


                    if (end == root.getEndOffset()) {

                        // 如果是文檔結(jié)束,則刪除前一行的回車,且跳到文檔結(jié)束的前一位置,其為行的有效位置

                        start = Math.max(0, start - 1); // 刪除前一行最后的回車

                        end--;

                    }

                    try {

                        getDocument().remove(start, end - start);


                        // 設(shè)置光標(biāo)在所在行的首行

                        lineNumber = root.getElementIndex(start);

                        e = root.getElement(lineNumber);

                        start = e.getStartOffset();

                        setCaretPosition(start);

                    } catch (BadLocationException e2) {

                        e2.printStackTrace();

                    }


                    /*

                    start = Math.max(0, start - 1); // 刪除前一行最后的回車

                    end = Math.min(end, root.getEndOffset() - 1); //

                    // 最后一行的時(shí)候,要往前跳一個(gè)位置跳過文檔結(jié)束符

                    // System.out.println("Start:" + start + ", End: " + end);


                    if (start == 0) {

                        getDocument().remove(start, end - start); // 第一行的時(shí)候,要把第一行尾的回車刪除

                    } else if (end + 1 == root.getEndOffset()) {

                        getDocument().remove(start, end - start);


                        // 最后一行時(shí),刪除后設(shè)置光標(biāo)到行的最前面

                        pos = root.getElement(root.getElementIndex(start)).getStartOffset();

                        setCaretPosition(pos);

                    } else {

                        getDocument().remove(start, end - start - 1); // 刪除前一行的回車,留這一行的回車

                        setCaretPosition(start + 1); // 設(shè)置光標(biāo)在下一行的首行

                    }*/

                }

            posted on 2010-05-22 01:12 逛奔的蝸牛 閱讀(372) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Java
            青青久久精品国产免费看| 97久久超碰国产精品2021| 久久久国产精品| 中文字幕无码久久久| 国内精品久久久久影院优| 久久综合九色综合久99| 伊人色综合久久天天人手人婷| 97精品依人久久久大香线蕉97 | 久久久国产精品网站| 欧美色综合久久久久久| 精品熟女少妇av免费久久| 久久久久99精品成人片牛牛影视 | 久久综合中文字幕| 少妇无套内谢久久久久| 欧美久久精品一级c片片| 久久婷婷五月综合色奶水99啪| 久久久久国产| 999久久久国产精品| 久久99热只有频精品8| 精品人妻伦九区久久AAA片69| 亚洲综合婷婷久久| 久久九九有精品国产23百花影院| 久久亚洲私人国产精品vA| 国产精品久久久久久五月尺| 久久AAAA片一区二区| 狠狠色伊人久久精品综合网 | 久久久这里有精品中文字幕| AAA级久久久精品无码区| 久久狠狠色狠狠色综合| 精品人妻久久久久久888| 久久久无码人妻精品无码| 国产69精品久久久久观看软件| 无码乱码观看精品久久| 欧美久久亚洲精品| 久久婷婷五月综合97色直播| 国产69精品久久久久观看软件 | 久久成人国产精品一区二区| 很黄很污的网站久久mimi色| 久久精品国产精品亜洲毛片| 久久精品中文字幕一区| 香蕉99久久国产综合精品宅男自|