I'm learning to use notcurses by my own way. I've created a program to transcribe DNA into RNA. Here is the code
#include <notcurses/notcurses.h>
#include <string>
using namespace std;
bool verify(int c, string &dna)
{
if (c == 'a' || c == 'A' || c == 'g' || c == 'G' ||
c == 'u' || c == 'U' || c == 'c' || c == 'C' ||
c == 't' ||
c == 'T') // Includes 't' and 'T' in valid characters
{
dna += static_cast<char>(c);
return true;
}
return false;
}
string rna(const string &dna)
{
string rna;
for (char c : dna)
{
if (c == 't' || c == 'T')
rna += 'u';
else
rna += c;
}
return rna;
}
int main()
{
string dna;
int c;
notcurses_options options = {};
notcurses *app = notcurses_init(&options, stdout);
if (!app)
{
fprintf(stderr, "Error initializing Notcurses\n");
return 1;
}
ncplane *stdplane = notcurses_stdplane(app);
// Clear screen at start
ncplane_erase(stdplane);
ncplane_putstr(stdplane, "Enter the DNA code (press 'q' to quit):");
notcurses_render(app);
while ((c = notcurses_get_blocking(app, nullptr)) != 'q')
{
if (verify(c, dna))
{
ncplane_putchar(stdplane, static_cast<char>(c));
notcurses_render(app);
}
}
ncplane_putstr(stdplane, "\nTranscribed RNA: ");
notcurses_render(app);
ncplane_putstr(stdplane, rna(dna).c_str());
notcurses_render(app);
// Wait for user to press 'q' to exit
while (notcurses_get_blocking(app, nullptr) != 'q')
;
notcurses_stop(app);
return 0;
}
When I add a newline to the beginning of a string, it doesn't print using ncplane_putstr, or when I do something like ncplane_putchar(stdplane, '\n') it doesn't work. I'm using Termux to program.
I'm learning to use notcurses by my own way. I've created a program to transcribe DNA into RNA. Here is the code
When I add a newline to the beginning of a string, it doesn't print using ncplane_putstr, or when I do something like
ncplane_putchar(stdplane, '\n')
it doesn't work. I'm using Termux to program.