C++ :: Ncurses - Highlighting A Line Of Characters On Screen
Oct 25, 2013
I am writing a program using ncurses that needs a function to highlight a line of characters on the screen. I started writing this function that took the x & y coordinates of a character on the screen and the length of characters after that to highlight. Whilst doing this I noticed that if I highlighted the last character in a row (maxX-1 in my example) it highlighted that character (as expected), and if I highlighted just the character before that (maxX-2) it also works. But if I do both, it highlights the whole row/line. Also, if there are characters in those spaces other than the 'space' character it works too, but for my program I need to be able to highlight empty spaces as well.
To highlight I am using inch() to get the character and addch() to print it because I am using some alternate characters that chgat() replaces with normal characters.
#include <ncurses.h>
int main(){
initscr();
start_color();
use_default_colors();
curs_set(0);
noecho();
int maxX=0, maxY=0;
[Code] ....
View 3 Replies
ADVERTISEMENT
Jun 29, 2013
I wanted to make the terminal screen bigger in my NCurses program. Let's say if the defaults are 25 LINES and 80 COLS, I want to set them to 40 LINES and 120 COLS.
I've tried resizing all windows, but that did not work, because the actual terminal (console) was not resized. Then I found functions resizeterm and newterm, but they did not work. As far as my understanding goes resizeterm only updates NCurses information with the current configuration, while the window itself is not actually modified.
NCurses man page wrote:The function resizeterm resizes the standard and current windows to the specified dimensions
If I haven't made myself clear ( I sometimes make a mess of things... ), another example would be that I want my program to be fullscreen when I start it. Is this possible? It should be, I found a fullscreen NCurses program once, but the code was too confusing for me to understand.
Having read about things like SIGWINCH, I assume you must define a method for resizing the terminal screen yourself, I don't know where to start?
View 11 Replies
View Related
Dec 3, 2013
How to move a character (an arrow or any other character) on screen using keyboard? I'm actually a beginner and have only wrote simple (starter's) programs in C++. It would be great without using any external library which is not included in C++ by default (in other words, using plain C++).
View 8 Replies
View Related
Jan 17, 2015
make a text file full of vocabulary wordsRead in that file and allow the user to specify the .doc file (should be simple)Go through the .doc file and highlight all the words that appear in the .txt file green.Open the .doc after the process is complete.
After I accomplish that, I can try to make more tweaks by maybe using a database instead for my vocabulary words and implementing error checking to be sure there are no duplicate entries, specify a different color for certain words instead of using just one color, etc. First and foremost, however, I want to know if the bare basics would be possible. I'm new to C++, but I have about 2yrs of Java under my belt, so I should be able to catch on relatively fast.
View 1 Replies
View Related
Apr 7, 2013
I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:
Code:
#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>
#include <vector>
using namespace std;
int main(){
vector <string> words;
string str, paieska;
[Code] .....
How to print line(s) where I found that word?
View 9 Replies
View Related
Jun 15, 2013
I seem to be missing a concept or 2 here ... I am tasked with writing a program that reads text from a file and outputs each line to the screen as well as to another file PRECEDED by a line number ...
In addition, I have to Print the line number at the start of the line and right-adjusted in a field of 3 spaces ...
Follow the line number with a colon then 1 space, then the text of the line.
Another kicker, is I have to grab the data 1 character at a time and write code to ignore leading blanks on each line.
Here is what I have so far:
#include <iostream>
#include <conio.h>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cctype>
using namespace std;
int main() {
char next;
int count = 0;
[Code] ....
View 7 Replies
View Related
Feb 5, 2013
void printList(int list[],int cnt,int numsPerLine){
for(int i=0;i<cnt;i++){
cout<<list[i]<<" ";
if((i%numsPerLine)==0)
cout<<"
";
} }
So cnt is 20, numsPerLine is 10, and list[] is initialized with a const = 20
i%numsPerLine on the first loop equals 0 and thus outputs a new line.
I'd like it to new line after 10.
View 1 Replies
View Related
May 10, 2013
This is a small program that reads a line from the screen, takes the ASCII values from the entered text, and edits it. Next, the ASCII values are reinterpreted (am i misspelling?) as text, and displayed. However, my final output has (allways?) at least 7 characters, even if you enter only one. I'm also trying to accomplish, that the part of the string which isn't filled, will be printed empty. In spaces.
compiled with -std=c99.
Code:
#include <stdio.h>
int main(){
int maxsize;
printf("How long is your message?
[Code] .....
View 6 Replies
View Related
Mar 10, 2015
parsing integers and characters in same line.
I trying to parse g8,7.
{
token = strtok(NULL, ",");
token2 = strtok(NULL, "g");
}
I am trying to make 8 an integer so that i get two integers 8 and 7.
I already know how to get 7, but every time i do it i get (0,7) instead of (8,7).
View 8 Replies
View Related
Jul 10, 2013
I'm trying to print Chinese/unicode characters to a line printer(EPSON LQ-2090) using the writePrinter method in c++.
ANSI characters print fine, but when I throw the buffer of widechar Chinese characters at it, they come out like garbage/ANSI chars.
while debuging string shows chinese characters but in memory it shows ANSI characters not chinese and these ANSI characters are get printed on printer.
Note that if I change the DocInfo datatype parameter to "TEXT" instead of "RAW" then also the Chinese characters donot print.
Is there a way to get Chinese or unicode characters to print correctly?
View 6 Replies
View Related
Sep 3, 2013
It's written here: URL....But those links don't work. I can't understand how to start programming using ncurses.
View 9 Replies
View Related
May 19, 2013
The following code works perfectly with "normal" C++
#include <iostream>
#include <vector>
int main() {
std::vector <std::string> hello {
[Code] ....
This prints "HELLO" on the screen. A function a bit more like NCurses is:
for (std::vector <std::string>::const_iterator it = hello.begin(); it != hello.end(); it++) {
std::string temp = *it;
std::cout << temp.c_str() << std::endl;
}
This still works with "normal" C++. Now, how do I get this working with NCurses? I tried
#include <curses.h>
#include <string>
#include <vector>
int main() {
initscr();
[Code] ....
But this just gives me an empty screen.
View 2 Replies
View Related
Feb 16, 2013
I've been assigned to program rogue using the ncurses library, which will need
1. File I/O
2. String parsing
3. User input (h,j,k,l)
4. Room drawing
And Where i can start with this program?
View 4 Replies
View Related
Aug 12, 2013
I'm makeing a card game with ncurses. I have all the card and player objects in order but i'm stuck trying to get the gui to work.
I'm using multiple windows for different players deck and pile. Now to the problem: I can get all the windows to show with borders in the console but i can't get any content printed in the windows and I rally can't see why!?
I have been reading the guide on [URL] but I don't get any further on the problem right now.
PS. the complete code incl. Makefile can be found at:
github.com/DanBrehmer/cardGame
#ifndef GUI_H
#define GUI_H
#include <ncurses.h>
[Code]....
View 3 Replies
View Related
Mar 7, 2014
How can a mulitline string be read line by line
ex: str = "PERIOD="week"
DAY="day"
TIME="time"";
View 2 Replies
View Related
Mar 20, 2014
so my question is i want to print characters,no string just an array of characters,i do this but it s not working,maybe i have to put the '' at the end?
Code:
int main() {
int i;
char ch[5];
for(i = 0; i < 5; i++) {
scanf("%c",&ch[i]);
[Code]...
View 6 Replies
View Related
Jul 6, 2014
Im supposed to find the common characters between two string characters, assuming that the user wont input duplicate letters like ddog. When I run my code I get an output of a question mark upside down. Here is my code with comments on what each part is supposed to do
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str1[20], str2[20],remp = '