2009-07-08 68 views
1

我想開發一個屏幕選擇工具,忽略選擇中的前導空格和數字。在屏幕內忽略linenumber的選擇

問題

  1. 什麼是影響選擇的工具C-a Esc在屏幕的代碼?
  2. 要使該忽略linenumbers並從選擇開始的空間的算法:

alt text http://files.getdropbox.com/u/175564/%20selection-less.png

以下Perl的正則表達式似乎匹配行的開頭

{5}[1-9]{1-4} {8}   # not tested 

選擇工具顯然是通過將選擇的增加與當前選擇連接起作用。例如,選擇一條線。我選擇另一個:將新行添加到選擇隊列中。選擇減少也是相反的。

我想在選擇符合\n時使用Perl正則表達式,以便考慮行的無知。

回答

5

我想你想選擇列。這比正則表達式要容易得多。

screen手冊頁:

c or C to set the left or right margin respectively. If no 
    repeat count is given, both default to the current 
    cursor position. 
    Example: Try this on a rather full text screen: "C-a [ 
    M 20 l SPACE c 10 l 5 j C SPACE". 

    This moves one to the middle line of the screen, moves 
    in 20 columns left, marks the beginning of the paste 
    buffer, sets the left column, moves 5 columns down, sets 
    the right column, and then marks the end of the paste 
    buffer. Now try: 
    "C-a [ M 20 l SPACE 10 l 5 j SPACE" 

    and notice the difference in the amount of text copied. 

所以,在你的屏幕截圖,按C-a [,將光標移動到你的文字,按SPACE的開始,然後按c。移至所選內容的末尾,然後再次按SPACE。現在你有你想要的文字。

希望這不是太多的信息。你用初學者標記了它,所以我不確定你是Perl還是屏幕初學者。

+0

@seth:謝謝你的回答! ---你的答案確實是一條捷徑。 ---我對哪些代碼會影響`c`下的按鈕感興趣。你知道`c`下的函數代碼在哪裏嗎? – 2009-07-09 12:56:31