mirror of
https://github.com/theKapcioszek/fremen-transcriptor.git
synced 2025-04-19 03:27:55 +02:00
added ability to input text in real time
This commit is contained in:
parent
5980bb8210
commit
535a1de855
10
README.md
10
README.md
@ -4,12 +4,20 @@ Sofware to transcript ASCII into desert people's writing from popular sci-fi fra
|
|||||||
|
|
||||||
## Quick start:
|
## Quick start:
|
||||||
|
|
||||||
|
if you want to pass phrase as an argument:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
make
|
make
|
||||||
./fremen <your text>
|
./fremen <your text>
|
||||||
```
|
```
|
||||||
|
if you want to input text in real time:
|
||||||
|
|
||||||
|
```console
|
||||||
|
make
|
||||||
|
./fremen
|
||||||
|
```
|
||||||
|
|
||||||
## TODO:
|
## TODO:
|
||||||
- [ ] Add text box instead of passing an argument
|
- [X] Add text box instead of passing an argument
|
||||||
- [ ] WebAssembly compilation
|
- [ ] WebAssembly compilation
|
||||||
- [ ] Option to save result as an image
|
- [ ] Option to save result as an image
|
||||||
|
67
src/main.c
67
src/main.c
@ -1,6 +1,4 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
@ -36,28 +34,16 @@ enum Character {
|
|||||||
U
|
U
|
||||||
};
|
};
|
||||||
|
|
||||||
char TextBuffer[MAX_STRING_LENGTH + 1] = "\0";
|
void transcript(char* message, int *charcters){
|
||||||
int LetterCount = 0;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
|
||||||
|
|
||||||
int msglen = 0;
|
|
||||||
|
|
||||||
if(argc > 1){
|
|
||||||
msglen = strlen(argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int charcters[100] = {0};
|
|
||||||
char message[msglen];
|
|
||||||
|
|
||||||
if(argc > 1){
|
|
||||||
|
|
||||||
strcpy(message, argv[1]);
|
|
||||||
|
|
||||||
for(int i = 0; message[i]; i++){
|
for(int i = 0; message[i]; i++){
|
||||||
message[i] = tolower(message[i]);
|
message[i] = tolower(message[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 100; i++){
|
||||||
|
charcters[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < strlen(message); i++){
|
for(int i = 0; i < strlen(message); i++){
|
||||||
switch (message[i]){
|
switch (message[i]){
|
||||||
case 'b':
|
case 'b':
|
||||||
@ -70,7 +56,7 @@ int main(int argc, char *argv[]){
|
|||||||
charcters[i] = M;
|
charcters[i] = M;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if(argv[1][i+1] == 'h'){
|
if(message[i+1] == 'h'){
|
||||||
charcters[i] = TH;
|
charcters[i] = TH;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -79,7 +65,7 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if(argv[1][i+1] == 'h'){
|
if(message[i+1] == 'h'){
|
||||||
charcters[i] = DH;
|
charcters[i] = DH;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -91,7 +77,7 @@ int main(int argc, char *argv[]){
|
|||||||
charcters[i] = N;
|
charcters[i] = N;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if(argv[1][i+1] == 'h'){
|
if(message[i+1] == 'h'){
|
||||||
charcters[i] = SH;
|
charcters[i] = SH;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -106,7 +92,7 @@ int main(int argc, char *argv[]){
|
|||||||
charcters[i] = J;
|
charcters[i] = J;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
if(argv[1][i+1] == 'h'){
|
if(message[i+1] == 'h'){
|
||||||
charcters[i] = KH;
|
charcters[i] = KH;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -115,7 +101,7 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
if(argv[1][i+1] == 'h'){
|
if(message[i+1] == 'h'){
|
||||||
charcters[i] = GH;
|
charcters[i] = GH;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -160,11 +146,30 @@ int main(int argc, char *argv[]){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%d %d %d %d %s \n",charcters[0], charcters[1], charcters[2], charcters[3], message);
|
}
|
||||||
|
|
||||||
|
char TextBuffer[MAX_STRING_LENGTH + 1] = "\0";
|
||||||
|
int LetterCount = 0;
|
||||||
|
bool cmd_flag = false;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
|
int msglen = 0;
|
||||||
|
|
||||||
|
if(argc > 1){
|
||||||
|
msglen = strlen(argv[1]);
|
||||||
|
cmd_flag = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printf("Provide a word as an argument\n");
|
msglen = MAX_STRING_LENGTH;
|
||||||
return 1;
|
}
|
||||||
|
|
||||||
|
int charcters[100] = {0};
|
||||||
|
char message[msglen];
|
||||||
|
|
||||||
|
if(cmd_flag == true){
|
||||||
|
strcpy(message, argv[1]);
|
||||||
|
transcript(message, charcters);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitWindow(800, 600, "Fremen Transcriptor");
|
InitWindow(800, 600, "Fremen Transcriptor");
|
||||||
@ -212,6 +217,9 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(!WindowShouldClose()){
|
while(!WindowShouldClose()){
|
||||||
|
|
||||||
|
transcript(message, charcters);
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground((Color){255,212,94,255});
|
ClearBackground((Color){255,212,94,255});
|
||||||
@ -229,7 +237,7 @@ int main(int argc, char *argv[]){
|
|||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
||||||
//INPUT
|
//INPUT
|
||||||
|
if(cmd_flag == false){
|
||||||
int PressedKey = GetCharPressed();
|
int PressedKey = GetCharPressed();
|
||||||
|
|
||||||
while(PressedKey > 0){
|
while(PressedKey > 0){
|
||||||
@ -251,7 +259,8 @@ int main(int argc, char *argv[]){
|
|||||||
TextBuffer[LetterCount] = '\0';
|
TextBuffer[LetterCount] = '\0';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
strcpy(message, TextBuffer);
|
||||||
|
}
|
||||||
//INPUT
|
//INPUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user