NEDIT_require_macro_file("extensions.nm") NEDIT_require_macro_file("RSextensions.nm") NEDIT_require_macro_file("RScolor.nm") # ============================================================================== # goThereSunCC(): attempt to move to a line in a file specified by the current # line in "CC output" format from Sun's CC/cc compilers, ie # "", line :. # Any following lines starting with tabs are included as content, part of # a compiler message. It colors the current line (and subsequent content # lines referencing the same destination), then attempts to open the file # mentioned and go to the line number. If this works, a calltip is # produced for the newly opened/raised file document, with the message # content. # ============================================================================== define goThereSunCC { $gothere[""] = 0 if ("CC output" in $gothere) { kill_calltip($gothere["CC output"]) delete $gothere["CC output"] } directory = $file_path if (directory == "") directory = $NEDIT_START_DIR "/" lineNo = 0 file = "" #if ($selection_start == -1) # { # get the current line beg = start_of_line_pos() end = end_of_line_pos() str = line_of_pos() # } #else # { # str = get_selection() # beg = $selection_start # end = $selection_end # } # color the selection found RangeSet_forget("CC output") RangeSet_add("CC output", beg, end + 1) RangeSet_set_color("CC output", "#80c0df") RangeSet_forget("CC output top") RangeSet_add("CC output top", beg, end + 1) RangeSet_set_color("CC output top", "#a0e0FF") # look for contiguous lines with the same prefix of form # "", line :content msg = "" fpos = search_string(str, "(?<=\")[^\"]+(?=\")", 0, "regex") if (fpos != -1) { file = substring(str, fpos, $search_end) filepath = replace_in_string(file, "[^/]*$", "", "regex", "copy") } pos = search_string(str, "(?<= line )[0-9]+(?=:|$)", 0, "regex") if (pos != -1) { lineNo = substring(str, pos, $search_end) prefix = substring(str, 0, $search_end) prefixQ = quote_literal_as_regex(prefix) prefixQL = "^" quote_literal_as_regex(prefix) ".*\n" posx = beg endx = beg for (posx = search(prefixQL, posx, "regex"); \ posx == endx; \ posx = search(prefixQL, endx, "regex")) { endx = $search_end msg = msg replace_in_string(get_range(posx, endx), prefix, "", "case") # any more info? These will be lines starting with tabs extra = search("(?:\t.*\n)+", endx, "regex") if (extra == endx) { posx = endx endx = $search_end extra = get_range(posx, endx) msg = msg replace_in_string(extra, "^\t", " ", "regex") } } msg = substring(msg, 0, -1) msg = replace_in_string(msg, filepath, "", "case", "copy") # there may be text at the front of the string to pick up too if (fpos != -1) { extra = substring(str, 0, fpos - 1) msg = replace_in_string(extra, "^\t", " ", "regex") msg } RangeSet_add("CC output", beg, endx) } if (lineNo != 0 && file != "") { # new_f = NEDIT_reduce_filename(file) # if (new_f == "") # new_f = NEDIT_reduce_filename(directory file) # file = new_f dialog_msg = "Could not find file:\n " file full_file = NEDIT_find_file_in_pathlist(file, directory "\n.") if (full_file == "") { # see if we don't have a file of that name in the current directory or # below basefile = replace_in_string(file, "^.*/", "", "regex", "copy") list = shell_command("find " $file_path " -name " basefile " -print", "") # filter results for the correct file name filefilter = "^(?!/.*(?<=/)" quote_literal_as_regex(basefile) ").*\n" list = replace_in_string(list, filefilter, "", "regex", "copy") if ($shell_cmd_status == 0 && list != "") { dialog_msg = dialog_msg "\nSelect one of the following (if correct):" file = list_dialog(dialog_msg, list, "OK", "Cancel") if (file != "" && $list_dialog_button == 1) full_file = NEDIT_find_file_in_pathlist(file, directory "\n.") else return } } if (full_file != "") { open(full_file) focus_window(full_file) goto_line_number(lineNo) if (msg != "") { msg = break_lines_over(150, msg) $gothere["CC output"] = calltip(msg, -1, "tipText") } } else { dialog(dialog_msg) } } else dialog("Could not determine file name (" file ") or line number (" lineNo ")") }