Example #1
0
File: ed.c Project: pharus/ed
Line
LineReadText(int len, FILE *f)
{
	Line l = NULL, b = NULL, a = NULL;
	int i = 0;


	while (!feof(f)) {
		if (!l) {
			l = LineCreate(i, len);
			b = l;
		} else {
			a = l;
			l->next = LineCreate(i, len);
			l = l->next;
		}
		BufferReadline(l->b, f);

		if (!l->b->buf[0]) {
			a->next = NULL;
			LineDestroy(l);
		}
		i++;
	}

	return b;
}
Example #2
0
File: ed.c Project: pharus/ed
int
main(int argc, char *argv[])
{
	FILE * f;
	Line l, ptr;

	if (argc > 1) {
		printf("Trying to open %s\n", argv[1]);
		f = fopen(argv[1], "r");

		if (!f) {
			perror(argv[1]);
			exit(1);
		}

		l = LineReadText(SIZE_OF_BUFFER,f);
		ptr = l;
		printf("%p\n", (void*) ptr);
		ptr = l;

		while (ptr) {
			printf("%d -> %s", ptr->n, ptr->b->buf);
			if (!ptr->b->buf[0])
				printf("Shit\n");
			ptr = ptr->next;
		}

		LineDestroy(l);

		fclose(f);
	} else {
		puts("Two arguments please");
	}
	

	return 0;
}
Example #3
0
//функция обработки сообщений (функция окна) 
LRESULT CALLBACK  WndProc(HWND hwnd, UINT msg,
											WPARAM wParam, LPARAM lParam)
{

	int x,y;
	switch(msg)
	{
		case WM_CREATE:
			LineCreate();
			break;

		case WM_PAINT:
//			InvalidateRect(hwnd,NULL,TRUE);
			LinePicture(hwnd,1);
			break;

		case WM_SIZE:
			InvalidateRect(hwnd,NULL,TRUE);
			break;

		case WM_LBUTTONDOWN:
			x = LOWORD(lParam);
			y = HIWORD(lParam);
			LineLButtonDown(hwnd,x,y);
			break;

		case WM_LBUTTONUP:
			LineLButtonUp(hwnd);
			LinePicture(hwnd,2);
			break;


		case WM_MOUSEMOVE:
			x = LOWORD(lParam);
			y = HIWORD(lParam);
			LineMouseMove( hwnd,x,y);
			break;

		case WM_KEYDOWN:
			switch(wParam)
			{
				case VK_LEFT:
					angl.fi += 10;
					LinePicture(hwnd,2);
					break;

				case VK_RIGHT:
					angl.fi -= 10;
					LinePicture(hwnd,2);
					break;

				case VK_UP:
					angl.teta += 10;
					LinePicture(hwnd,2);
					break;

				case VK_DOWN:
					angl.teta -= 10;
					LinePicture(hwnd,2);
					break;
			}
			break;

		case WM_DESTROY:
			LineDestroy();
			break;

		default:
			return DefWindowProc(hwnd,msg,wParam,lParam);
	}

	return 0L;
}