• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

練習用です。いろんなものがごちゃまぜです。


Commit MetaInfo

Revision23 (tree)
Time2015-08-25 14:56:12
Authorbellyoshi

Log Message

Change Summary

Incremental Difference

--- vs2015/edline/edline/edline.c (nonexistent)
+++ vs2015/edline/edline/edline.c (revision 23)
@@ -0,0 +1,128 @@
1+#define _CRT_SECURE_NO_WARNINGS
2+
3+#include <ctype.h>
4+#include <stdio.h>
5+#include <stdlib.h>
6+#include <string.h>
7+
8+#define MAX_CHAR 65536
9+#define FORMAT "%5d:%s"
10+#define NOT_SET -1
11+#define SUCCESS 0
12+#define ERROR_ARGUMENT_NUMBER 1
13+#define ERROR_CANNOT_OPEN_FILE 2
14+#define ERROR_CANNOT_CLOSE_FILE 3
15+
16+char *ErrorMessage[4] = {
17+ "成功",
18+ "ファイル名を指定してください(-?でヘルプ)",
19+ "ファイルを開けませんでした。",
20+ "ファイルを閉じれませんでした。"
21+};
22+
23+char *HelpMessage =
24+"a:追加(行頭のCtrl+Zで終了)\n"
25+"d:削除([1d][1-2d]のように行指定)\n"
26+"i:挿入([1i]のように行指定、行頭のCtrl+Zで終了)\n"
27+"l:表示([2l][2-5l]のように行指定)\n"
28+"q:終了\n(行番号):編集\n";
29+
30+char *FileName;
31+char **Line = NULL;
32+int LineCount = 0;
33+
34+void Append();
35+void Delete(int start, int end);
36+void Edit(int start);
37+char GetCommandChar(char *command);
38+int GetStart(char *command);
39+int GetEnd(char *command);
40+void Insert(int start);
41+int Interact();
42+void List(int start, int end);
43+int LoadFile(char *fileName);
44+int Quit();
45+int SaveFile(char *fileName);
46+
47+int main(int argc, char *argv[]) {
48+ int i;
49+ int result = SUCCESS;
50+
51+ if (argc != 2) {
52+ result = ERROR_ARGUMENT_NUMBER;
53+ }
54+ else {
55+ if (argv[1][0] == '-') {
56+ switch (argv[1][1]) {
57+ case 'v':
58+ printf("edline Version 0.01 2015(c) yoshihiro watanabe\n");
59+ return result;
60+ case 'h':
61+ printf("ラインエディタedline\n\n"
62+ "起動方法:%s ファイル名\n\n"
63+ "コマンド:\n%s", argv[0], HelpMessage);
64+ return result;
65+ }
66+ }
67+ FileName = argv[1];
68+ result = LoadFile(FileName);
69+ printf("%s:", FileName);
70+ if (result == ERROR_CANNOT_OPEN_FILE) {
71+ printf("新しいファイルです。\n");
72+ } else {
73+ printf("%d行読み込みました。\n", LineCount);
74+ }
75+ result = Interact();
76+ }
77+
78+ for (i = 0; i < LineCount; i++) {
79+ if (Line[i]) {
80+ free(Line[i]);
81+ }
82+ }
83+ if (Line) {
84+ free(Line);
85+ }
86+
87+ if (result != SUCCESS) {
88+ printf("%s\n", ErrorMessage[result]);
89+ }
90+ return result;
91+}
92+
93+void Append() {
94+
95+}
96+void Delete(int start, int end) {
97+
98+}
99+void Edit(int start) {
100+
101+}
102+char GetCommandChar(char *command) {
103+ return '\0';
104+}
105+int GetStart(char *command) {
106+ return 0;
107+}
108+int GetEnd(char *command) {
109+ return 0;
110+}
111+void Insert(int start) {
112+
113+}
114+int Interact() {
115+ return 0;
116+}
117+void List(int start, int end) {
118+
119+}
120+int LoadFile(char *fileName) {
121+ return 0;
122+}
123+int Quit() {
124+ return 0;
125+}
126+int SaveFile(char *fileName) {
127+ return 0;
128+}
\ No newline at end of file