我已经为<复制选择性显示>加载了一个宏,宏名称是copy_shown()。我可以通过绑定到某个键来运行命令。但是如何在不绑定密钥的情况下运行它?我尝试使用的宏是 Mathew 编写的 - 请参阅 < Slickedit forum thread >。
////////////////////////////////////////////////////////////////////////////////////////////
#include "slick.sh"
/*
Copy the lines currently shown in the current buffer to the clipboard. This
should ignore lines that are hidden because of selective display settings.
*/
_command void copy_shown()
{
int lines_copied = 0;
// Create a new buffer to hold the displayed lines.
int tempWID;
int prevWID = _create_temp_view(tempWID);
// Switch back to the previous buffer to find the lines to copy.
p_window_id = prevWID;
// Place cursor on line 0 before first line of the buffer.
top(); up();
// Iterate across the lines in the buffer, copying those that are not hidden.
for (j=1; j<=p_Noflines; j++) {
// Go down and get the next line.
if (down()) break;
get_line(line);
// If this line is not hidden, copy it to the new buffer.
if (!(_lineflags() & HIDDEN_LF)) {
// Copy the line.
lines_copied++;
tempWID.insert_line(line);
}
}
if (lines_copied == 0) {
message('No displayed lines found!');
}
else {
// Activate the temp view to copy the lines
p_window_id = tempWID;
select_all();
copy_to_clipboard();
// Switch back to original view
p_window_id = prevWID;
s = lines_copied==1 ? '' : 's';
message(lines_copied ' line's ' copied to this buffer.');
}
// Clean up the temp view
_delete_temp_view(tempWID);
}
////////////////////////////////////////////////////////////////////////////////////////////