cncursespdcurses

weird ncurses behaviour compared to pdcurses


I am working on a text editor project that uses pdcurses for tui

here is the code : https://github.com/abdelrahman1215/simple-txt.git

but since it uses pdcurses it was only availible on windows , so i tried to make it work on linux by making it include and link against ncurses when building on linux , and while it compiles it doesn't work like the windows version at all

windows version :

screenshot1

linux version :

screenshot2

i could narrow it down and say the proplem is propably in src/display/display_txt.c but are there any linking errors or any thing else that might cause this

here is a minimal version of the main.c file that leads to the same outcome :

#include "../headers/parse_term_args.h"
#include "../headers/simple_globals.h"
#include "../headers/curses_header.h"
#include "../headers/init_display.h"
#include "../headers/msg_fmt.h"
#include "../headers/display.h"

#include <stdlib.h>

int main(int argc , char **argv){
    parse_term_args(argc , argv);
    display_messages();

    if(Current_File == NULL){
        if(stdscr != NULL){
            endwin();
        }

        return 0;
    }

    Current_Mode = Normal_Mode;
    Quit = false;

    if(stdscr == NULL){
        init_display();
    }

    text_display_info *save_text_info = new_text_disp_info();
    update_text_display(Current_File , save_text_info , stdscr , BACKGROUND , TEXT , LINE_HIGHLIGHT , SIDE_STRIPS , SIDE_STRIP_HIGHLIGHT , Least_V_Distance , Least_H_Distance , true , Relative_Line_Number , true , true , true , 0 , 0 , 0 , 0);

    for(int ch = getch() ; ch == ERR ; ch = getch()){}

    endwin();
}

note : the q's are caused by using chgat on a line made hline , but if it works like the windows version this shouldn't happen


Solution

  • turns out that the problem was that i opened files from DOS/Windows origin which contains the character ^M at the end of each line , the windows version of fread doesn't read this character , but the linux version does leading to this problem , so the soultion was to make my loading function not copy the ^Ms read by fread