• <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>

            逛奔的蝸牛

            我不聰明,但我會很努力

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

                /**

                 * 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); // 取得光標所在行的行號

                    Element e = root.getElement(lineNumber);


                    int start = e.getStartOffset();

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


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

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

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

                        end--;

                    }

                    try {

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


                        // 設置光標在所在行的首行

                        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); //

                    // 最后一行的時候,要往前跳一個位置跳過文檔結束符

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


                    if (start == 0) {

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

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

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


                        // 最后一行時,刪除后設置光標到行的最前面

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

                        setCaretPosition(pos);

                    } else {

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

                        setCaretPosition(start + 1); // 設置光標在下一行的首行

                    }*/

                }

            posted on 2010-05-22 01:12 逛奔的蝸牛 閱讀(371) 評論(0)  編輯 收藏 引用 所屬分類: Java
            囯产极品美女高潮无套久久久| 精品熟女少妇AV免费久久 | 久久亚洲欧美国产精品| 久久天天躁狠狠躁夜夜2020一 | 国产精品天天影视久久综合网| 久久婷婷国产麻豆91天堂| 久久久91人妻无码精品蜜桃HD| 久久亚洲中文字幕精品一区| 99久久精品影院老鸭窝| 久久久久一本毛久久久| 久久久久亚洲AV无码永不| 精品久久久久久国产牛牛app| 精品久久久无码人妻中文字幕| 99久久精品这里只有精品| 国内精品久久久久久久久电影网 | 久久精品亚洲中文字幕无码麻豆| 国产三级精品久久| 日韩久久久久久中文人妻| 久久福利片| 国产精品99久久久久久猫咪| 久久久无码人妻精品无码| 少妇无套内谢久久久久| 久久国产成人午夜AV影院| 国产精品对白刺激久久久| 久久精品卫校国产小美女| 久久久久国产一级毛片高清板| 狠狠色丁香久久综合婷婷| 久久亚洲精品成人AV| 亚洲人成电影网站久久| 99久久国产亚洲高清观看2024| 精品国产乱码久久久久久郑州公司 | 丰满少妇人妻久久久久久| 久久人妻AV中文字幕| 久久只有这里有精品4| 中文字幕精品久久| 狠狠色丁香久久婷婷综合蜜芽五月| 久久免费香蕉视频| 久久久久国产| 欧美黑人激情性久久| 2021国内久久精品| 99久久无色码中文字幕人妻|