Index: uspace/app/edit/edit.c
===================================================================
--- uspace/app/edit/edit.c	(revision c8444d8a7a95232c11e935845e636bebff590218)
+++ uspace/app/edit/edit.c	(revision 7d27f422ee7822eb3b75e43fd8ced187eb45d3f3)
@@ -91,5 +91,5 @@
 typedef struct {
 	char *file_name;
-	sheet_t sh;
+	sheet_t *sh;
 } doc_t;
 
@@ -175,4 +175,5 @@
 	coord_t coord;
 	bool new_file;
+	int rc;
 
 	spt_t pt;
@@ -189,10 +190,14 @@
 
 	/* Start with an empty sheet. */
-	sheet_init(&doc.sh);
+	rc = sheet_create(&doc.sh);
+	if (rc != EOK) {
+		printf("Out of memory.\n");
+		return -1;
+	}
 
 	/* Place caret at the beginning of file. */
 	coord.row = coord.column = 1;
-	sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt);
-	sheet_place_tag(&doc.sh, &pt, &pane.caret_pos);
+	sheet_get_cell_pt(doc.sh, &coord, dir_before, &pt);
+	sheet_place_tag(doc.sh, &pt, &pane.caret_pos);
 	pane.ideal_column = coord.column;
 
@@ -216,5 +221,5 @@
 	/* Place selection start tag. */
 	tag_get_pt(&pane.caret_pos, &pt);
-	sheet_place_tag(&doc.sh, &pt, &pane.sel_start);
+	sheet_place_tag(doc.sh, &pt, &pane.sel_start);
 
 	/* Initial display */
@@ -447,7 +452,7 @@
 	if (select == false) {
 		/* Move sel_start to the same point as caret. */
-		sheet_remove_tag(&doc.sh, &pane.sel_start);
+		sheet_remove_tag(doc.sh, &pane.sel_start);
 		tag_get_pt(&pane.caret_pos, &pt);
-		sheet_place_tag(&doc.sh, &pt, &pane.sel_start);
+		sheet_place_tag(doc.sh, &pt, &pane.sel_start);
 	}
 
@@ -670,5 +675,5 @@
 
 	do {
-		sheet_copy_out(&doc.sh, &sp, epos, buf, BUF_SIZE, &bep);
+		sheet_copy_out(doc.sh, &sp, epos, buf, BUF_SIZE, &bep);
 		bytes = str_size(buf);
 
@@ -705,5 +710,5 @@
 
 	while (true) {
-		sheet_copy_out(&doc.sh, &sp, epos, &buf[bpos], buf_size - bpos,
+		sheet_copy_out(doc.sh, &sp, epos, &buf[bpos], buf_size - bpos,
 		    &bep);
 		bytes = str_size(&buf[bpos]);
@@ -727,5 +732,5 @@
 	int sh_rows, rows;
 
-	sheet_get_num_rows(&doc.sh, &sh_rows);
+	sheet_get_num_rows(doc.sh, &sh_rows);
 	rows = min(sh_rows - pane.sh_row + 1, pane.rows);
 
@@ -797,13 +802,13 @@
 		rbc.row = pane.sh_row + i;
 		rbc.column = pane.sh_column;
-		sheet_get_cell_pt(&doc.sh, &rbc, dir_before, &rb);
+		sheet_get_cell_pt(doc.sh, &rbc, dir_before, &rb);
 
 		/* Ending point for row display */
 		rec.row = pane.sh_row + i;
 		rec.column = pane.sh_column + pane.columns;
-		sheet_get_cell_pt(&doc.sh, &rec, dir_before, &re);
+		sheet_get_cell_pt(doc.sh, &rec, dir_before, &re);
 
 		/* Copy the text of the row to the buffer. */
-		sheet_copy_out(&doc.sh, &rb, &re, row_buf, ROW_BUF_SIZE, &dep);
+		sheet_copy_out(doc.sh, &rb, &re, row_buf, ROW_BUF_SIZE, &dep);
 
 		/* Display text from the buffer. */
@@ -874,14 +879,17 @@
 	spt_t caret_pt;
 	coord_t coord;
+	int last_row;
 
 	tag_get_pt(&pane.caret_pos, &caret_pt);
 	spt_get_coord(&caret_pt, &coord);
 
+	sheet_get_num_rows(doc.sh, &last_row);
+
 	const char *fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>";
 
 	console_set_pos(con, 0, scr_rows - 1);
 	console_set_style(con, STYLE_INVERTED);
-	int n = printf(" %d, %d: File '%s'. Ctrl-Q Quit  Ctrl-S Save  "
-	    "Ctrl-E Save As", coord.row, coord.column, fname);
+	int n = printf(" %d, %d (%d): File '%s'. Ctrl-Q Quit  Ctrl-S Save  "
+	    "Ctrl-E Save As", coord.row, coord.column, last_row, fname);
 	
 	int pos = scr_columns - 1 - n;
@@ -919,5 +927,5 @@
 	cbuf[offs] = '\0';
 
-	(void) sheet_insert(&doc.sh, &pt, dir_before, cbuf);
+	(void) sheet_insert(doc.sh, &pt, dir_before, cbuf);
 
 	pane.rflags |= REDRAW_ROW;
@@ -936,7 +944,7 @@
 
 	coord.column -= 1;
-	sheet_get_cell_pt(&doc.sh, &coord, dir_before, &sp);
-
-	(void) sheet_delete(&doc.sh, &sp, &ep);
+	sheet_get_cell_pt(doc.sh, &coord, dir_before, &sp);
+
+	(void) sheet_delete(doc.sh, &sp, &ep);
 
 	pane.rflags |= REDRAW_ROW;
@@ -954,8 +962,8 @@
 	spt_get_coord(&sp, &sc);
 
-	sheet_get_cell_pt(&doc.sh, &sc, dir_after, &ep);
+	sheet_get_cell_pt(doc.sh, &sc, dir_after, &ep);
 	spt_get_coord(&ep, &ec);
 
-	(void) sheet_delete(&doc.sh, &sp, &ep);
+	(void) sheet_delete(doc.sh, &sp, &ep);
 
 	pane.rflags |= REDRAW_ROW;
@@ -1029,9 +1037,9 @@
 		else {
 			coord.row--;
-			sheet_get_row_width(&doc.sh, coord.row, &coord.column);
+			sheet_get_row_width(doc.sh, coord.row, &coord.column);
 		}
 	}
 	if (drow > 0) {
-		sheet_get_num_rows(&doc.sh, &num_rows);
+		sheet_get_num_rows(doc.sh, &num_rows);
 		if (coord.row > num_rows) coord.row = num_rows;
 	}
@@ -1046,7 +1054,7 @@
 	 * coordinates. The character can be wider than one cell (e.g. tab).
 	 */
-	sheet_get_cell_pt(&doc.sh, &coord, align_dir, &pt);
-	sheet_remove_tag(&doc.sh, &pane.caret_pos);
-	sheet_place_tag(&doc.sh, &pt, &pane.caret_pos);
+	sheet_get_cell_pt(doc.sh, &coord, align_dir, &pt);
+	sheet_remove_tag(doc.sh, &pane.caret_pos);
+	sheet_place_tag(doc.sh, &pt, &pane.caret_pos);
 
 	/* For non-vertical movement set the new value for @c ideal_column. */
@@ -1068,6 +1076,6 @@
 		tag_get_pt(&pane.caret_pos, &pt);
 
-		sheet_remove_tag(&doc.sh, &pane.sel_start);
-		sheet_place_tag(&doc.sh, &pt, &pane.sel_start);
+		sheet_remove_tag(doc.sh, &pane.sel_start);
+		sheet_place_tag(doc.sh, &pt, &pane.sel_start);
 	} while (!pt_is_word_beginning(&pt));
 
@@ -1084,6 +1092,6 @@
 		tag_get_pt(&pane.caret_pos, &pt);
 
-		sheet_remove_tag(&doc.sh, &pane.sel_start);
-		sheet_place_tag(&doc.sh, &pt, &pane.sel_start);
+		sheet_remove_tag(doc.sh, &pane.sel_start);
+		sheet_place_tag(doc.sh, &pt, &pane.sel_start);
 	} while (!pt_is_word_beginning(&pt));
 
@@ -1163,7 +1171,7 @@
 
 	if (rel < 0)
-		sheet_delete(&doc.sh, &pa, &pb);
+		sheet_delete(doc.sh, &pa, &pb);
 	else
-		sheet_delete(&doc.sh, &pb, &pa);
+		sheet_delete(doc.sh, &pb, &pa);
 
 	if (ca.row == cb.row)
@@ -1187,8 +1195,8 @@
 static void selection_sel_range(spt_t pa, spt_t pb)
 {
-	sheet_remove_tag(&doc.sh, &pane.sel_start);
-	sheet_place_tag(&doc.sh, &pa, &pane.sel_start);
-	sheet_remove_tag(&doc.sh, &pane.caret_pos);
-	sheet_place_tag(&doc.sh, &pb, &pane.caret_pos);
+	sheet_remove_tag(doc.sh, &pane.sel_start);
+	sheet_place_tag(doc.sh, &pa, &pane.sel_start);
+	sheet_remove_tag(doc.sh, &pane.caret_pos);
+	sheet_place_tag(doc.sh, &pb, &pane.caret_pos);
 
 	pane.rflags |= REDRAW_TEXT;
@@ -1273,5 +1281,5 @@
 
 	coord.row = coord.column = 1;
-	sheet_get_cell_pt(&doc.sh, &coord, dir_before, pt);
+	sheet_get_cell_pt(doc.sh, &coord, dir_before, pt);
 }
 
@@ -1282,9 +1290,9 @@
 	int num_rows;
 
-	sheet_get_num_rows(&doc.sh, &num_rows);
+	sheet_get_num_rows(doc.sh, &num_rows);
 	coord.row = num_rows + 1;
 	coord.column = 1;
 
-	sheet_get_cell_pt(&doc.sh, &coord, dir_after, pt);
+	sheet_get_cell_pt(doc.sh, &coord, dir_after, pt);
 }
 
@@ -1297,5 +1305,5 @@
 	coord.column = 1;
 
-	sheet_get_cell_pt(&doc.sh, &coord, dir_before, spt);
+	sheet_get_cell_pt(doc.sh, &coord, dir_before, spt);
 }
 
@@ -1307,8 +1315,8 @@
 
 	spt_get_coord(cpt, &coord);
-	sheet_get_row_width(&doc.sh, coord.row, &row_width);
+	sheet_get_row_width(doc.sh, coord.row, &row_width);
 	coord.column = row_width - 1;
 
-	sheet_get_cell_pt(&doc.sh, &coord, dir_after, ept);
+	sheet_get_cell_pt(doc.sh, &coord, dir_after, ept);
 }
 
@@ -1336,5 +1344,5 @@
 
 	coord.column -= 1;
-	sheet_get_cell_pt(&doc.sh, &coord, dir_before, &lp);
+	sheet_get_cell_pt(doc.sh, &coord, dir_before, &lp);
 
 	return pt_is_delimiter(&lp)
@@ -1358,5 +1366,5 @@
 
 	coord.column += 1;
-	sheet_get_cell_pt(&doc.sh, &coord, dir_after, &rp);
+	sheet_get_cell_pt(doc.sh, &coord, dir_after, &rp);
 
 	ch = range_get_str(pt, &rp);
@@ -1384,5 +1392,5 @@
 
 	coord.column += 1;
-	sheet_get_cell_pt(&doc.sh, &coord, dir_after, &rp);
+	sheet_get_cell_pt(doc.sh, &coord, dir_after, &rp);
 
 	ch = range_get_str(pt, &rp);
