home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
editor
/
me
/
cols.m
< prev
next >
Wrap
Text File
|
1994-01-31
|
1KB
|
66 lines
/* These macros perform columnar copy and paste. There are no need for */
/* these macros, since these operations are built in to ME. */
int col_id;
init()
{
assign_key("col_copy", 3); /* <CTRL> C */
assign_key("col_paste", 16); /* <CTRL> P */
col_id = 0;
}
col_copy()
{
int line1, line2, col1, col2, width;
int old_id;
string str, foo;
line1 = marked_line(); col1 = marked_col();
line2 = currlinenum(); col2 = currcol();
if (col_id <= 0) col_id = create_buffer("$col$.$$$");
old_id = currbuf();
width = col2 - col1 + 1;
goline(line1); setcol(col1);
while (currlinenum() <= line2)
{
str = substr(currline(), col1, width);
setcurrbuf(col_id);
gobol();
insert(str);
insert("\n");
setcurrbuf(old_id);
setcol(col1); down();
}
clear_mark();
}
col_paste()
{
int old_id;
string str;
old_id = currbuf();
setcurrbuf(col_id);
goline(1); gobol();
while (currlinenum() < lastlinenum())
{
str = currline();
setcurrbuf(old_id);
save_position();
insert(str);
restore_position();
down();
setcurrbuf(col_id);
if (!down()) break;
}
setcurrbuf(old_id);
}