示例#1
0
void string_append_line(ustring & container, const ustring & line)
{
  if (!container.empty()) {
    container.append("\n");
  }
  container.append(line);
}
示例#2
0
void bibleworks_define_parsing_conjunction_suffix (ustring& parsing, ustring& definition)
// Parse the suffix of the conjunction.
{
  if (parsing == "c")
    definition.append (" contracted");
  if (parsing == "n")
    definition.append (" not contracted");
}
示例#3
0
void bibleworks_define_parsing_particle_suffix (ustring& parsing, ustring& definition)
// Parse the suffix of the particle.
{
  if (parsing == "i")
    definition.append (" interrogative");
  if (parsing == "n")
    definition.append (" negative");
  if (parsing == "o")
    definition.append (" other");
}
示例#4
0
void bibleworks_define_parsing_adjective_suffix (ustring& parsing, ustring& definition)
// Parse the suffix of the adjective.
{
  if (parsing == "c")
    definition.append (" comparative");
  if (parsing == "s")
    definition.append (" superlative");
  if (parsing == "n")
    definition.append (" no degree");
}
示例#5
0
void bibleworks_define_parsing_adverb_suffix (ustring& parsing, ustring& definition)
// Parse the suffix of the adverb.
{
  if (parsing == "c")
    definition.append (" comparative");
  if (parsing == "s")
    definition.append (" superlative");
  if (parsing == "i")
    definition.append (" interrogative");
  if (parsing == "n")
    definition.append (" normal");
}
示例#6
0
void notes_read_one_from_file (int id, ustring& note, ustring& project, ustring& references, ustring& category, int& date_created, ustring& user_created, int& date_modified, ustring& logbook)
{
    note.clear();
    logbook.clear();
    ustring filename = notes_file_name (id);
    ReadText rt (filename, true, false);
    bool logbook_indicator_encountered = false;
    for (unsigned int i = 0; i < rt.lines.size(); i++) {
        ustring line = rt.lines[i];
        if (i == 0) {
            // Retrieve date created.
            date_created = convert_to_int (line);
        }
        else if (i == 1) {
            // Retrieve user who created it.
            user_created = line;
        }
        else if (i == 2) {
            // Retrieve references.
            references = line;
        }
        else if (i == 3) {
            // Retrieve category.
            category = line;
        }
        else if (i == 4) {
            // Retrieve project.
            project = line;
        }
        else if (i == 5) {
            // Retrieve date modified.
            date_modified = convert_to_int (line);
        }
        else if (line == notes_logbook_line ()) {
            logbook_indicator_encountered = true;
        }
        else {
            if (logbook_indicator_encountered) {
                if (!logbook.empty()) logbook.append ("\n");
                logbook.append (line);
            } else {
                if (!note.empty()) note.append ("\n");
                note.append (line);
            }
        }
    }
    note = trim (note);
    logbook = trim (logbook);
}
示例#7
0
void bibleworks_define_parsing_gender (ustring& parsing, ustring& definition)
// Parse the gender.
{
  ustring gender_code = parsing.substr (0, 1);
  parsing.erase (0, 1);
  if (gender_code == "m") {
    definition.append (" masculine");
  } 
  if (gender_code == "f") {
    definition.append (" feminine");
  }
  if (gender_code == "n") {
    definition.append (" neuter");
  }
}
示例#8
0
void compress_ensure_zip_suffix (ustring& filename)
// Ensure that "filename" has the ".zip" suffix.
{
  if (!g_str_has_suffix (filename.c_str(), ".zip")) {
    filename.append (".zip");
  }
}
示例#9
0
void bibleworks_define_parsing_number (ustring& parsing, ustring& definition)
// Parse the number.
{
  ustring number = parsing.substr (0, 1);
  bool remove_code = true;
  if (number == "s") {
    definition.append (" singular");
  } else if (number == "p") {
    definition.append (" plural");
  } else {
    remove_code = false;
  }
  if (remove_code) {
    parsing.erase (0, 1);
  }
}
示例#10
0
void ExportParatextStylesheet::save (ustring filename)
{
  // Write the stylesheet to file.
  if (!g_str_has_suffix (filename.c_str(), ".sty")) {
    filename.append (".sty");
  }
  write_lines (filename, stylesheet_lines);
}
示例#11
0
void bibleworks_define_parsing_person (ustring& parsing, ustring& definition)
// This looks in the "parsing" whether the person is given. 
// If so, it adds the description to the "definition" and removes the relevant code from the "parsing".
{
  ustring person = parsing.substr (0, 1);
  bool person_found = true;
  if (person == "1") {
    definition.append (" first person");
  } else if (person == "2") {
    definition.append (" second person");
  } else if (person == "3") {
    definition.append (" third person");
  } else {
    person_found = false;
  }
  if (person_found) {
    parsing.erase (0, 1);
  }
}
示例#12
0
void bibleworks_define_parsing_case (ustring& parsing, ustring& definition)
// Parse the case.
{
  ustring case_code = parsing.substr (0, 1);
  parsing.erase (0, 1);
  if (case_code == "n") {
    definition.append (" nominative");
  } 
  if (case_code == "g") {
    definition.append (" genitive");
  }
  if (case_code == "d") {
    definition.append (" dative");
  }
  if (case_code == "a") {
    definition.append (" accusative");
  }
  if (case_code == "v") {
    definition.append (" vocative");
  }
}
示例#13
0
void bibleworks_define_parsing_pronoun (ustring& parsing, ustring& definition)
// Parse the extra bits of the pronoun.
{
  ustring code = parsing.substr (0, 1);
  parsing.erase (0, 1);
  if (code == "r") {
    definition.append (" relative");
  }
  if (code == "e") {
    definition.append (" reciprocal");
  }
  if (code == "d") {
    definition.append (" demonstrative");
  }
  if (code == "c") {
    definition.append (" correlative");
  } 
  if (code == "q") {
    definition.append (" interrogative");
  }
  if (code == "i") {
    definition.append (" indefinite");
  }
  if (code == "o") {
    definition.append (" correlative/interrogative");
  }
  if (code == "x") {
    definition.append (" reflexive");
  }
  if (code == "s") {
    definition.append (" possessive");
  }
  if (code == "p") {
    definition.append (" personal");
  }
}
示例#14
0
void bibleworks_define_parsing_voice (ustring& parsing, ustring& definition)
// Parse the voice of verbs.
{
  ustring voice = parsing.substr (0, 1);  
  parsing.erase (0, 1);
  if (voice == "a")
    definition.append (" active");
  if (voice == "m")
    definition.append (" middle");
  if (voice == "p")
    definition.append (" passive");
  if (voice == "e")
    definition.append (" middle or passive");
  if (voice == "d")
    definition.append (" middle deponent");
  if (voice == "o")
    definition.append (" passive deponent");
  if (voice == "n")
    definition.append (" middle or passive deponent");
  if (voice == "q")
    definition.append (" impersonal active");
  if (voice == "x")
    definition.append (" no voice stated");
}
示例#15
0
void bibleworks_define_parsing_indeclinable_form_suffix (ustring& parsing, ustring& definition)
// Parse the suffix of the indeclinable form.
{
  if (parsing == "a")
    definition.append (" Aramaic word");
  if (parsing == "h")
    definition.append (" Hebrew word");
  if (parsing == "p")
    definition.append (" indeclinable noun");
  if (parsing == "n")
    definition.append (" indeclinable numeral");
  if (parsing == "l")
    definition.append (" indeclinable letter");
  if (parsing == "o")
    definition.append (" indeclinable other");
}
示例#16
0
void bibleworks_define_parsing_tense (ustring& parsing, ustring& definition)
// Parse the tense of verbs.
{
  ustring tense = parsing.substr (0, 1);  
  parsing.erase (0, 1);
  if (tense == "p")
    definition.append (" present");
  if (tense == "i")
    definition.append (" imperfect");
  if (tense == "f")
    definition.append (" future");
  if (tense == "a")
    definition.append (" aorist");
  if (tense == "x")
    definition.append (" perfect");
  if (tense == "y")
    definition.append (" pluperfect");
}
示例#17
0
void bibleworks_define_parsing_mood (ustring& parsing, ustring& definition)
// Parse the mood of verbs.
{
  ustring mood = parsing.substr (0, 1);  
  parsing.erase (0, 1);
  if (mood == "i")
    definition.append (" indicative");
  if (mood == "s")
    definition.append (" subjunctive");
  if (mood == "o")
    definition.append (" optative");
  if (mood == "d")
    definition.append (" imperative");
  if (mood == "n")
    definition.append (" infinitive");
  if (mood == "p")
    definition.append (" participle");
}
示例#18
0
void notes_display_internal(const ustring& language, bool show_reference_text, bool show_summary, ustring& note_buffer, unsigned int id, const gchar * text, unsigned int cursor_id, unsigned int &cursor_offset)
{
    // Optionally display the extra text.
    if (text) {
        note_buffer.append(text);
        note_buffer.append("<BR>\n");
    }

    // Get data from the note file.
    ustring note;
    ustring project;
    ustring reference;
    ustring category;
    int date_created;
    ustring user_created;
    int date_modified;
    ustring logbook;
    notes_read_one_from_file (id, note, project, reference, category, date_created, user_created, date_modified, logbook);

    // Parse the reference(s) string into its possible several references.
    Parse parse(reference, false);
    reference.clear();

    // Keep list of references.
    vector <Reference> references;

    // Go through each reference.
    for (unsigned int i2 = 0; i2 < parse.words.size(); i2++) {
        // Make it human readable.
        Reference oldRef;
        Reference newRef;
        reference_discover(oldRef, parse.words[i2], newRef);
        if (!reference.empty()) {
            reference.append(", ");
        }
        reference.append(newRef.human_readable(language));
        references.push_back(newRef);
    }

    // Start creating the heading with links.
    ustring linkheading;
    // If this note is to be focused, then insert a special anchor for that:
    // <a name="cursoranchor" id="cursoranchor"></a>
    if (id == cursor_id) {
        linkheading.append ("<a name=\"");
        linkheading.append (notes_cursor_anchor());
        linkheading.append ("\" id=\"");
        linkheading.append (notes_cursor_anchor());
        linkheading.append ("\"></a>");
    }
    extern Settings * settings;
    if (settings->session.project_notes_show_title) {
        // Insert a link with this heading, e.g.: <a href="10">Genesis 1.1</a>
        linkheading.append("<a href=\"" + convert_to_string(id) + "\">");
        linkheading.append(reference);
        if (settings->genconfig.notes_display_project_get())
            linkheading.append(" " + project);
        if (settings->genconfig.notes_display_category_get())
            linkheading.append(" " + category);
        if (settings->genconfig.notes_display_date_created_get())
            linkheading.append(" " + date_time_julian_human_readable(date_created, true));
        if (settings->genconfig.notes_display_created_by_get())
            linkheading.append(" " + user_created);
        linkheading.append("</a>");
        // Append a [delete] link too, e.g.: <a href="d10">[delete]</a>
        linkheading.append(" <a href=\"d" + convert_to_string(id) + "\">");
        linkheading.append("[delete]");
        linkheading.append("</a>");
        // Append a [references] link too, e.g.: <a href="r10">[references]</a>
        linkheading.append(" <a href=\"r" + convert_to_string(id) + "\">");
        linkheading.append("[references]");
        linkheading.append("</a>");
    }
    // Add the heading to the note data.
    note_buffer.append(linkheading);

    // Handle summary. Show only the first few words.
    if (show_summary) {
        ustring summary = note;
        replace_text(summary, "\n", " ");
        replace_text(summary, "<BR>", " ");
        Parse parse(summary, false);
        unsigned int maximum = 5;
        maximum = CLAMP(maximum, 0, parse.words.size());
        summary.clear();
        for (unsigned int w = 0; w < maximum; w++) {
            summary.append(" ");
            summary.append(parse.words[w]);
        }
        if (!summary.empty())
            summary.append(" ...");
        note_buffer.append(summary);
    }
    // Append a new line.
    note_buffer.append("<BR>\n");

    // Insert text of the references, if requested.
    if (show_reference_text) {
        for (unsigned int r = 0; r < references.size(); r++) {
            vector <unsigned int> simple_verses = verse_range_sequence(references[r].verse_get());
            for (unsigned int sv = 0; sv < simple_verses.size(); sv++) {
                Reference ref(references[r]);
                ref.verse_set(convert_to_string(simple_verses[sv]));
                note_buffer.append(ref.human_readable(language));
                note_buffer.append(" ");
                ustring text = project_retrieve_verse(project, ref);
                if (!text.empty()) {
                    text = usfm_get_verse_text_only (text);
                }
                note_buffer.append(text);
                note_buffer.append("<BR>\n");
            }
        }
    }
    // Get the text of the note.
    if (!show_summary) {
        note_buffer.append(note);
        note_buffer.append("<BR>\n");
    }
}
示例#19
0
void CategorizeLine::append_text(ustring & container, const ustring & text)
{
  if (!container.empty()) { container.append(" "); }
  container.append(text);
}
示例#20
0
FloatingWindow::FloatingWindow(GtkWidget * layout_in, WindowID window_id_in, ustring title_in, bool startup)
// Base class for each floating window.
{
  // If there's no title the configuration file would get inconsistent. 
  // Put something there.
  if (title_in.empty()) {
    title_in.append(_("Untitled"));
  }

  // Initialize variables.
  layout = layout_in;
  title = title_in;
  window_id = window_id_in;
  dragging_window = false;
  resizing_window = false;
  my_shutdown = false;
  clear_previous_root_coordinates ();
  last_focused_widget = NULL;
  focused = false;
  resize_event_id = 0;
    
  // Signalling buttons.
  focus_in_signal_button = gtk_button_new();
  delete_signal_button = gtk_button_new();

  gtkbuilder = gtk_builder_new ();
  gtk_builder_add_from_file (gtkbuilder, gw_build_filename (Directories->get_package_data(), "gtkbuilder.floatingwindow.xml").c_str(), NULL);

  vbox_window = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "vbox_window"));

  GtkWidget *eventbox_title;
  eventbox_title = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "eventbox_title"));
  label_title = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_title"));
  title_set (focused);
  g_signal_connect ((gpointer) eventbox_title, "button_press_event", G_CALLBACK (on_widget_button_press_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_title, "button_press_event", G_CALLBACK (on_title_bar_button_press_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_title, "button_release_event", G_CALLBACK (on_title_bar_button_release_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_title, "motion_notify_event", G_CALLBACK (on_title_bar_motion_notify_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_title, "enter_notify_event", G_CALLBACK (on_titlebar_enter_notify_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_title, "leave_notify_event", G_CALLBACK (on_titlebar_leave_notify_event), gpointer (this));
    
  GtkWidget *eventbox_close;
  eventbox_close = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "eventbox_close"));
  label_close = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_close"));
  g_signal_connect ((gpointer) eventbox_close, "button_press_event", G_CALLBACK (on_widget_button_press_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_close, "enter_notify_event", G_CALLBACK (on_label_close_enter_notify_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_close, "leave_notify_event", G_CALLBACK (on_label_close_leave_notify_event), gpointer (this));
  g_signal_connect ((gpointer) eventbox_close, "button_press_event", G_CALLBACK (on_label_close_button_press_event), gpointer (this));

  GtkWidget *eventbox_client;
  eventbox_client = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "eventbox_client"));
  vbox_client = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "vbox_client"));
  g_signal_connect ((gpointer) eventbox_client, "button_press_event", G_CALLBACK (on_widget_button_press_event), gpointer (this));

  GtkWidget *eventbox_status1;
  eventbox_status1 = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "eventbox_status1"));
  label_status1 = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_status1"));
  g_signal_connect ((gpointer) eventbox_status1, "button_press_event", G_CALLBACK (on_widget_button_press_event), gpointer (this));

  GtkWidget *eventbox_status2;
  eventbox_status2 = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "eventbox_status2"));
  label_status2 = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_status2"));
  g_signal_connect ((gpointer) eventbox_status2, "button_press_event", G_CALLBACK (on_widget_button_press_event), gpointer (this));

  widget_resizer = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "widget_resizer"));
  g_signal_connect ((gpointer) widget_resizer, "button_press_event", G_CALLBACK (on_widget_button_press_event), gpointer (this));
  g_signal_connect ((gpointer) widget_resizer, "button_press_event", G_CALLBACK (on_status_bar_button_press_event), gpointer (this));
  g_signal_connect ((gpointer) widget_resizer, "button_release_event", G_CALLBACK (on_status_bar_button_release_event), gpointer (this));
  g_signal_connect ((gpointer) widget_resizer, "motion_notify_event", G_CALLBACK (on_status_bar_motion_notify_event), gpointer (this));
  g_signal_connect ((gpointer) widget_resizer, "enter_notify_event", G_CALLBACK (on_statusbar_enter_notify_event), gpointer (this));
  g_signal_connect ((gpointer) widget_resizer, "leave_notify_event", G_CALLBACK (on_statusbar_leave_notify_event), gpointer (this));

  // Do the display handling.
  display(startup);
}
示例#21
0
void bitpattern_add(ustring & pattern, bool setting)
// Adds one bit for "setting" to "pattern".
{
  pattern.append(convert_to_string(setting));
}