Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.sao.ru/hq/sts/linux/doc/nedit/macro/4/4-08.shtml
Дата изменения: Unknown
Дата индексирования: Sat Sep 11 22:17:28 2010
Кодировка:

Поисковые слова: comet tail
NEdit.org

.
.   
NEdit.org
   .

Home
 - News - Download - Documentation - Search - FTP     
.
.
  

Dired

[Back]

The following allows you to display directories and open subdirectories/files. One limitation is that you can only view files under the directory hierarchy where you start NEdit.

Insert the following in your .nedit file, the default key bindings are:

Shift+Home go to and display NEdit startup directory
Shift+Enter go to selected directory or open selected file
F12 refresh directory listing (same as doing ls -laCF)

The cd/open macro has been changed so that:

  • Will now check if the last character in the selection is / rather than just the character after the selection.
  • If the first character in the selection is /, use the absolute path name. This resolves the problems of only viewing files under the directory in which you started.
  • Before trying to open a file, try to cd to that file. If no error is found, then it must also be a directory.
  • Changed the logic a bit so that it only calls Dired>ls once at the end.
  • If no selection exists, it will select the current word (bounded by whitespace).
Dired>Home:Shift+Home:o:: {
   if ($file_path == "")
      $nedit_cwd = "./"
   else
      $nedit_cwd = $file_path
   macro_menu_command("Dired>ls")
}
Dired>ls:F12::: {
   if ($nedit_cwd == "")
      $nedit_cwd = "./"
   select_all()
   delete()
   temp = " \\"" $nedit_cwd "\\""
   cmd = "cd "  temp "; ls -laCF"
   insert_string(shell_command(cmd,""))
   mesg = "Your current directory is " $nedit_cwd "\\n"
   insert_string(mesg)
}
Dired>cd/open:Shift+Return::: {
   # If no selection, select the current word
   if ($selection_start == -1) {
      start=search("( |\\t|^)",$cursor,"regex","backward")+1
      end=search("( |\\t|$)",$cursor,"regex")
      if (end == -1) {
         end=$text_length
      }
      # Handle case of first word in the file
      if (start == 1) {
         if (get_character(0) != " " && get_character(0) != "\\t") {
            start=0
         }
      }
      # Handle case of first word on the line
      if (get_character(start-2) == "\\n") {
         start=start-1
      }
      # Select text and return (click again to execute)
      select(start,end)
   }

   # Allow absolute paths
   if (get_character($selection_start) == "/") {
      $nedit_cwd = ""
   }

   # Ignore trailing "*"
   if (get_character($selection_end-1) == "*") {
      select($selection_start,$selection_end-1)
   }

   # should check character after selection or last char. of selection
   # if its "/", it's a dir, otherwise, open selection
   if (get_selection() == "." || get_selection() == "./") {
      # do nothing
      $nedit_cwd = $nedit_cwd
   } else if (get_selection() == ".." || get_selection() == "../") {
      # get rid of last directory
      fee = substring($nedit_cwd,0,search_string($nedit_cwd,"/[^/]+/$",1,"regex"))
      fee = fee "/"
      # handle case of going to "/" only
      if (fee == "/")
         $nedit_cwd = $file_path
      else
      $nedit_cwd = fee
   } else if (get_character($selection_end) == "/") {
      $nedit_cwd = $nedit_cwd get_selection() "/"
   } else if (get_character($selection_end-1) == "/") {
      $nedit_cwd = $nedit_cwd get_selection()
   } else {
      # Try and cd, checking for errors
      shell_command("cd " $nedit_cwd get_selection(),"")
      if ($shell_cmd_status == 0) {
         $nedit_cwd = $nedit_cwd get_selection() "/"
      } else {
      # nothing else - try to open file
      open($nedit_cwd get_selection())
      return
      }
   }
   # Browse new directory
   end_of_file()
   macro_menu_command("Dired>ls")
}
[Back]

. Released on  Wed, 21 Nov 2001  by C. Denat  

  
Visit our sponsor
Check Metrolink

© NEdit.org
1999-2001
All rights reserved


.