paint: open existing files for editing
This commit is contained in:
parent
cbb83c4fce
commit
cb3fdfb70f
2 changed files with 43 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
|||
.SH NAME
|
||||
paint \- create image files by drawing with a mouse or other pointing device
|
||||
.SH SYNOPSIS
|
||||
.B paint
|
||||
.B paint [file]
|
||||
.SH DESCRIPTION
|
||||
.I Paint
|
||||
provides a window upon which can be drawn lines by moving the cursor while
|
||||
|
@ -25,6 +25,9 @@ in the pop-up box and hit enter.
|
|||
.B c
|
||||
Clear the screen. Any unsaved work will be lost.
|
||||
.TP
|
||||
.B o
|
||||
Open a bitmap image file for editing.
|
||||
.TP
|
||||
.B s
|
||||
Save the current screen as a bitmap image. A pop-up box appears
|
||||
suggesting a default filename of
|
||||
|
|
|
@ -10,6 +10,22 @@ eresized(int)
|
|||
sysfatal("resize failed");
|
||||
}
|
||||
|
||||
void
|
||||
loadimg(char *name)
|
||||
{
|
||||
Image *b;
|
||||
int fd;
|
||||
|
||||
fd=open(name, OREAD);
|
||||
if(fd==-1)
|
||||
sysfatal("can't open file");
|
||||
if((b=readimage(display, fd, 0)) == nil)
|
||||
sysfatal("can't read image");
|
||||
draw(screen, screen->r, b, 0, b->r.min);
|
||||
flushimage(display, 1);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* stolen from mothra */
|
||||
void
|
||||
screendump(char *name, int full)
|
||||
|
@ -35,7 +51,7 @@ screendump(char *name, int full)
|
|||
}
|
||||
|
||||
void
|
||||
main()
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Event e;
|
||||
Point last;
|
||||
|
@ -52,6 +68,23 @@ main()
|
|||
einit(Emouse | Ekeyboard);
|
||||
draw(screen, screen->r, display->white, 0, ZP);
|
||||
flushimage(display, 1);
|
||||
|
||||
ARGBEGIN{
|
||||
default:
|
||||
goto Usage;
|
||||
}ARGEND
|
||||
switch(argc){
|
||||
default:
|
||||
Usage:
|
||||
fprint(2, "Usage: [file]\n");
|
||||
exits("usage");
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
loadimg(argv[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
while(1){
|
||||
switch(event(&e)){
|
||||
case Emouse:
|
||||
|
@ -79,6 +112,11 @@ main()
|
|||
}
|
||||
if(e.kbdc == 'c')
|
||||
draw(screen, screen->r, display->white, 0, ZP);
|
||||
if(e.kbdc == 'o'){
|
||||
if(eenter("Open file", file, sizeof(file), &e.mouse) <= 0)
|
||||
break;
|
||||
loadimg(file);
|
||||
}
|
||||
if(e.kbdc == 'q')
|
||||
exits(nil);
|
||||
if(e.kbdc == 's'){
|
||||
|
|
Loading…
Reference in a new issue