Added lincese header, files are now being opened with a+ mode.

This commit is contained in:
GrenderG committed 2017-04-08 02:14:32 +02:00
1 parent b440e82542
commit de8112ef3f
1 file changed
+19 -6
+19 -6
View File
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2017 Daniel Morales
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*** Include section ***/ /*** Include section ***/
// We add them above our includes, because the header // We add them above our includes, because the header
@@ -796,7 +813,7 @@ void editorOpen(char* file_name) {
editorSelectSyntaxHighlight(); editorSelectSyntaxHighlight();
FILE* file = fopen(file_name, "r"); FILE* file = fopen(file_name, "a+");
if (!file) if (!file)
die("Failed to open the file"); die("Failed to open the file");
@@ -997,11 +1014,7 @@ void editorDrawStatusBar(struct a_buf* ab) {
char status[80], r_status[80]; char status[80], r_status[80];
// Showing up to 20 characters of the filename, followed by the number of lines. // Showing up to 20 characters of the filename, followed by the number of lines.
int len = snprintf(status, sizeof(status), " Editing: %.20s %s", ec.file_name ? ec.file_name : "New file", ec.dirty ? "(modified)" : ""); int len = snprintf(status, sizeof(status), " Editing: %.20s %s", ec.file_name ? ec.file_name : "New file", ec.dirty ? "(modified)" : "");
int col_size; int col_size = ec.row && ec.cursor_y <= ec.num_rows - 1 ? col_size = ec.row[ec.cursor_y].size : 0;
if (ec.row && ec.cursor_y <= ec.num_rows - 1)
col_size = ec.row[ec.cursor_y].size;
else
col_size = 0;
int r_len = snprintf(r_status, sizeof(r_status), "%d/%d lines %d/%d cols ", ec.cursor_y + 1 > ec.num_rows ? ec.num_rows : ec.cursor_y + 1, ec.num_rows, int r_len = snprintf(r_status, sizeof(r_status), "%d/%d lines %d/%d cols ", ec.cursor_y + 1 > ec.num_rows ? ec.num_rows : ec.cursor_y + 1, ec.num_rows,
ec.cursor_x + 1 > col_size ? col_size : ec.cursor_x + 1, col_size); ec.cursor_x + 1 > col_size ? col_size : ec.cursor_x + 1, col_size);
if (len > ec.screen_cols) if (len > ec.screen_cols)